Guest User

Untitled

a guest
Apr 24th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. using UnityEngine;
  2.  
  3. using System.Collections;
  4.  
  5.  
  6.  
  7. public class testmovement : MonoBehaviour {
  8.  
  9. public float speed = 6.0F;
  10.  
  11. public float jumpSpeed = 8.0F;
  12.  
  13. public float gravity = 20.0F;
  14.  
  15. private Vector3 moveDirection = Vector3.zero;
  16.  
  17. void Update() {
  18.  
  19. CharacterController controller = GetComponent<CharacterController>();
  20.  
  21. if (controller.isGrounded) {
  22.  
  23. transform.forward * Input.GetAxis("Vertical") * speed;
  24.  
  25. moveDirection = new Vector3( 0, 0, 0);
  26.  
  27. moveDirection = transform.TransformDirection(moveDirection);
  28.  
  29. moveDirection *= speed;
  30.  
  31. if (Input.GetButton("snopp"))
  32.  
  33. moveDirection.y = jumpSpeed;
  34.  
  35. }
  36.  
  37. moveDirection.y -= gravity * Time.deltaTime;
  38.  
  39. controller.Move(moveDirection * Time.deltaTime);
  40.  
  41. }
  42.  
  43. }
Add Comment
Please, Sign In to add comment