Guest User

Untitled

a guest
Jan 19th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. var moveTouchPad : Joystick;
  2.  
  3. var Speed : float = 4;
  4.  
  5.  
  6.  
  7. function OnEndGame()
  8. {
  9. // Disable joystick when the game ends
  10. moveTouchPad.Disable();
  11.  
  12. if ( rotateTouchPad )
  13. rotateTouchPad.Disable();
  14.  
  15. // Don't allow any more control changes when the game ends
  16. this.enabled = false;
  17. }
  18.  
  19. function Update()
  20. {
  21. var movement = thisTransform.TransformDirection( Vector3( moveTouchPad.position.x, 0, moveTouchPad.position.y ) );
  22.  
  23.  
  24. // Apply movement from move joystick
  25. var absJoyPos = Vector2( Mathf.Abs( moveTouchPad.position.x ), Mathf.Abs( moveTouchPad.position.y ) );
  26. if ( absJoyPos.y > absJoyPos.x )
  27. {
  28. movement *= Speed * absJoyPos.y;
  29.  
  30. }
  31. else
  32. movement *= Speed * absJoyPos.x;
  33.  
  34. movement *= Time.deltaTime;
  35.  
  36. }
Add Comment
Please, Sign In to add comment