Created
May 5, 2011 22:36
-
-
Save N-Carter/958119 to your computer and use it in GitHub Desktop.
Simple ship controls
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected override void FixedUpdate() | |
{ | |
if(m_Controls != null) | |
{ | |
float turnFactor = Mathf.Lerp(1.0f, 0.5f, m_Controls.thrust); | |
rigidbody.AddRelativeTorque(Vector3.right * m_Controls.pitch * m_PitchFactor * turnFactor); | |
rigidbody.AddRelativeTorque(Vector3.forward * m_Controls.roll * m_RollFactor * turnFactor); | |
rigidbody.AddRelativeTorque(Vector3.up * m_Controls.yaw * m_YawFactor * turnFactor); | |
m_ThrustAxis.current = m_Controls.thrust; | |
m_ThrustAxis.Update(); | |
rigidbody.AddRelativeForce(Vector3.forward * (m_ThrustAxis.current * m_ThrustFactor + m_BaseThrust)); | |
Fire(0, m_Controls.primaryFire); | |
Fire(1, m_Controls.secondaryFire); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment