Peter Eldredge PPJ #2

Input Changes/Experimentation - 3 Hours
Group meeting about the project and tasks - 2 Hours
Game Design Document Help and Sell Pitch Help - 4 Hours

New Input Type


This week my main goal ended up being a refactor of the ship controller as well as the implementation of the new Mouse Control Scheme. I started by streamlining the options so they would be more compatible with an options menu, but currently the options are tied to inspector and keyboard inputs.

One of the biggest improvements in the refactor is that the actual inputs have been abstracted away from direct player movement. By doing this, we can now take input in unity's Update() as opposed to FixedUpdate(), which is where the movement actually occurs, leading to more responsive controls. It also allows us to set the input calculation as a delegate. This means that we can simply swap calculations from Mouse to Keyboard at runtime without side effects, even though their calculations are very different.


This is our Update() function currently. The direct look at specific keys is for the sake of testing and rapid development, but the overall functionality is extensible. When T is pressed, we swap the mouse movement variable and then call SetInputType(). This function determines the input type that will be used during the update function, and sets the delegate for the _inputCalculation accordingly. At the end of the update, that calculation is then used to set the Pitch and Roll.

Keyboard Calculation



The Keyboard Calculation is very basic, we just set the pitch equal to the vertical axis with smoothing (not raw) and then multiply it by the _invertYControl, which will either flip the sign or not depending on if inversion is set. The roll is literally just the smoothed horizontal axis.

Mouse Calculation



The mouse calculation is a fair bit more involved than the Keyboard. This is because we are in essence creating a virtual joystick from the starting location of the mouse. Because of this approach, we need to keep track of the distance the mouse is from the center of the joystick. This is tracked in the _xMousePosition and _yMousePosition members accordingly. Each Frame, they are updated with the distance the mouse traveled, divided by 100 to adjust the scale of the movement, multiplied by the appropriate sensitivity and inversion control. Then the absolute value of the mouse position is taken and compared against the deadzone. If that value is smaller than the deadzone, then the movement is 0 on that axis. Otherwise, we subtract out the deadzone distance (to allow for fine adjustments just outside the deadzone region) and set that equal to the corresponding movement variable, Pitch or Roll.

For added comfort, if you lost your center you can always reset the center of the virtual joystick by hitting Spacebar. This calls the ResetVirtualJoystick() function, which simply resets the _xMousePosition and _yMousePotition, creating a new origin.

Input Findings

Something that became very clear however, is that controller input is vastly superior in this case to the mouse and keyboard support. Even with the new customization and hours of experimentation, I was unable to make any keyboard or mouse controls feel nearly as good as a controller. I will leave in all the options and possibly expand upon them, as not everyone has a gamepad, but it is clear that is the best way to play.

Documentation

I worked primarily on the aspects relating to controls, technical specifications, and enemy specifications in the GDD. Additionally I gave input on several sections that Jake wrote, and we updated the Sales Pitch together.

Group Positives

It seems like we are going to get the requirements for the presentations and documentation done.

Group Negatives

This week we had the same issue as last. Meeting too late and not enough communication. This ended up leading to Jake doing the lions share of the documentation and not having the time to work on the game. Because of this, I ended up having to look into the input system, instead of continuing work on the enemy framework, and we are still in the same spot as we were last week. Finishing work on Thursday morning, something that I wanted to avoid. Additionally, the lack of communication means that we don't know what exactly everyone has been working on and how their parts are coming along. Overall, this was not a great week productivity wise, and I am glad Jake stepped up for the documentation, or I don't know how we would have gotten it done.

Upcoming

I am hoping next week I will be able to get back to the enemy framework, and am planning on doing all the stuff I was hoping to get done with it this week. This is what I said last week:

The Enemy Framework is going to get Movement Behaviors just like the Attack Behaviors, and this will function primarily as the game's AI. Additionally other types of attacks will need to be added as well as a damaging/destruction system for when the player destroys them. Overall a lot of components are missing, but they depend on what we decide for the design of the game and we have a good base to build from.

This still generally holds true, although we came up with some basic movements and some more attacks that I should be able to implement. Hopefully I will also be able to get some artwork for the enemies that I can implement.


Comments

Popular posts from this blog

Getting Started: In the Cloud(s) Sean McFadden Summary (PPJ #01)

Peter Eldredge PPJ #1