Created
July 25, 2016 07:32
-
-
Save urahimono/331b2bfcf68557f297753d620d85e0b9 to your computer and use it in GitHub Desktop.
UnityのCrossPlatformInputを使う その4 MobileAircraftControls編
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_cameraScale = 5.0f; | |
void Update() | |
{ | |
float horizontal = CrossPlatformInputManager.GetAxis( "Horizontal" ); | |
transform.position += Vector3.right * horizontal * m_speedScale * Time.deltaTime; | |
float vertical = CrossPlatformInputManager.GetAxis( "Vertical" ); | |
Camera.main.transform.position = new Vector3( 0.0f, 1.0f, -10.0f ) + Vector3.forward * vertical * m_cameraScale; | |
if( CrossPlatformInputManager.GetAxis( "Fire1" ) > 0 ) | |
{ | |
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