Created
July 25, 2016 06:44
-
-
Save urahimono/3536d1c84dce07fbc0c4053237d0e542 to your computer and use it in GitHub Desktop.
UnityのCrossPlatformInputを使う その2 CarTiltControls編
This file contains 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
using UnityEngine; | |
using UnityStandardAssets.CrossPlatformInput; | |
public class Test : MonoBehaviour | |
{ | |
[SerializeField] | |
private float m_speedScale = 0.1f; | |
[SerializeField] | |
private float m_turnSpeedScale = 45.0f; | |
private float m_moveSpeed = 0.0f; | |
private float m_turnSpeed = 0.0f; | |
void Update() | |
{ | |
m_moveSpeed += CrossPlatformInputManager.GetAxis( "Vertical" ) * m_speedScale; | |
m_moveSpeed = Mathf.Max( m_moveSpeed, 0.0f ); | |
m_turnSpeed = CrossPlatformInputManager.GetAxis( "Mouse X" ) * m_turnSpeedScale; | |
transform.position += transform.up * m_moveSpeed * Time.deltaTime; | |
transform.rotation *= Quaternion.AngleAxis( m_turnSpeed * Time.deltaTime, Vector3.back ); | |
} | |
} // class Test |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment