Created
July 25, 2016 07:09
-
-
Save urahimono/b7557fe39a7da27ddec332d7d823f428 to your computer and use it in GitHub Desktop.
UnityのCrossPlatformInputを使う その3 DualTouchControls編
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 = 5.0f; | |
[SerializeField] | |
private float m_turnSpeedScale = 45.0f; | |
private float m_turnSpeed = 0.0f; | |
void Update() | |
{ | |
float vertical = CrossPlatformInputManager.GetAxis( "Vertical" ); | |
float horizontal = CrossPlatformInputManager.GetAxis( "Horizontal" ); | |
Vector3 addPos = new Vector3( horizontal, vertical, 0.0f ) * m_speedScale; | |
transform.position += addPos * Time.deltaTime; | |
m_turnSpeed = CrossPlatformInputManager.GetAxis( "Mouse X" ) * m_turnSpeedScale; | |
transform.rotation *= Quaternion.AngleAxis( m_turnSpeed * Time.deltaTime, Vector3.back ); | |
if( CrossPlatformInputManager.GetButton( "Jump" ) ) | |
{ | |
GetComponent<Renderer>().material.color = Color.red; | |
} | |
else | |
{ | |
GetComponent<Renderer>().material.color = Color.white; | |
} | |
} | |
} // class Test |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment