Skip to content

Instantly share code, notes, and snippets.

@urahimono
Created July 25, 2016 06:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save urahimono/3536d1c84dce07fbc0c4053237d0e542 to your computer and use it in GitHub Desktop.
Save urahimono/3536d1c84dce07fbc0c4053237d0e542 to your computer and use it in GitHub Desktop.
UnityのCrossPlatformInputを使う その2 CarTiltControls編
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