
In this project, my primary focus was on crafting a seamlessly intuitive controller for piloting a combat spacecraft.
Remembering the elements I used to appreciate in dogfight games, I sought to learn and implement similar features in my own game.
The controller design that consistently stood out as both engaging and rewarding involved enhancing movement responsiveness towards the edges. Moreover, the strategic integration of a dead zone at the center of the screen was implemented to offer finer control. Together, these elements contribute to a more immersive and satisfying flying experience
I implemented it as demonstrated to achieve the outlined controller design:
private void calculateMouseLook(Vector2 mousePos)
{
Vector2 centerOfScreen = new Vector2(this.cam.pixelWidth / 2f, this.cam.pixelHeight / 2f);
Vector2 mouseFromCenter = mousePos / centerOfScreen; // Relative to the middle of the screen in percntage (normalization)
mouseFromCenter = new Vector2(mouseFromCenter.x - 1f, mouseFromCenter.y - 1f); // Changes the middle of the screen to be (0,0)
if (Mathf.Abs(mouseFromCenter.x) < deadzone)
mouseFromCenter.x = 0;
if (Mathf.Abs(mouseFromCenter.y) < deadzone)
mouseFromCenter.y = 0;
this.mouseLook.x = mouseFromCenter.x;
this.mouseLook.y = -mouseFromCenter.y;
this.mouseLook.x *= this.lookSensitivityX;
this.mouseLook.y *= this.lookSensitivityY;
}Now, the controller is a crucial component of gameplay, imparting a simpler and more intuitive feel to the player's actions. Yet, this alone falls short of providing the satisfaction players seek. Hence, there is a need to complement it with a fluid visual experience that is correlated with their actions.
To address this, I introduced a tilting feature to the spacecraft. Crafted to emulate the player's movements based on both speed and turning force, you'll notice a more pronounced tilt as speed increases and turns become more forceful, capturing the added force for maneuvering.
The tilt's intensity is carefully calibrated to enhance the player's input, crafting a natural connection between player actions and the spacecraft's responsive behavior. This intentional integration showcases my commitment to a gameplay design that's not just intuitive but also visually engaging for players.
I executed it as demonstrated, ensuring it aligns with the envisioned controller design:
private void Tilt()
{
float horizonalAxis = this.mouseLook.x;
if (this.rb.velocity.x == 0f && this.currentMaxVelocity < this.rb.velocity.magnitude)
this.currentMaxVelocity = this.rb.velocity.magnitude;
float velocityNormlized = this.rb.velocity.magnitude / this.currentMaxVelocity;
float horizontalAxisNormalized = horizonalAxis / this.GetComponent<CharacterInputManager>().LookSensitivityX;
float angle = (90 * (-horizontalAxisNormalized) * Mathf.Clamp(velocityNormlized, 0.15f, 1f));
Vector3 newRotaion = new Vector3(0, 0, angle);
this.spaceCraftModel.DOLocalRotate(newRotaion, 30f * Time.fixedDeltaTime, RotateMode.Fast);
}
