Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var moveTouchPad : Joystick;
- var Speed : float = 4;
- function OnEndGame()
- {
- // Disable joystick when the game ends
- moveTouchPad.Disable();
- if ( rotateTouchPad )
- rotateTouchPad.Disable();
- // Don't allow any more control changes when the game ends
- this.enabled = false;
- }
- function Update()
- {
- var movement = thisTransform.TransformDirection( Vector3( moveTouchPad.position.x, 0, moveTouchPad.position.y ) );
- // Apply movement from move joystick
- var absJoyPos = Vector2( Mathf.Abs( moveTouchPad.position.x ), Mathf.Abs( moveTouchPad.position.y ) );
- if ( absJoyPos.y > absJoyPos.x )
- {
- movement *= Speed * absJoyPos.y;
- }
- else
- movement *= Speed * absJoyPos.x;
- movement *= Time.deltaTime;
- }
Add Comment
Please, Sign In to add comment