Guest User

Untitled

a guest
Oct 20th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. public class Example : MonoBehaviour
  2. {
  3. public RigidBody body;
  4. public Vector3 velocity;
  5.  
  6. private bool _moveForward;
  7.  
  8. private void Update()
  9. {
  10. _moveForward = Input.GetKey("W");
  11. }
  12.  
  13. private void FixedUpdate()
  14. {
  15. if(_moveForward)
  16. {
  17. body.velocity = velocity;
  18. }
  19. //Else just let the object slow down on its own using the drag.
  20. }
  21. }
Add Comment
Please, Sign In to add comment