Advertisement
Guest User

Untitled

a guest
Dec 14th, 2018
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class CharacterMotor : MonoBehaviour {
  6.  
  7. // Animations du perso
  8. Animations animations;
  9.  
  10. // Vitesse de deplacement
  11. public float walkSpeed;
  12. public float runSpeed;
  13. public float turnSpeed;
  14.  
  15. // Inputs
  16. public string InputFront;
  17. public string InputBack;
  18. public string InputLeft;
  19. public string InputRight;
  20. public Vector3 jumpspeed;
  21. CapsuleCollider PlayerCollider;
  22.  
  23. // Use this for initialization
  24. void Start () {
  25. animations = gameObject.GetComponent<Animations>();
  26. playerCollider = gameObject.GetComponent<CapsuleCollider>();
  27.  
  28. }
  29.  
  30. // Update is called once per frame
  31. void Update () {
  32.  
  33. // si on avance
  34. if (input.Getkey(inputFront)) && Input.GetKey(KeyCode.leftShift))
  35. {
  36. transform.Translate(0,0, walkSpeed * time.deltaTime);
  37. animations.Play("walk");
  38. }
  39. // si on sprint
  40. if (input.Getkey(inputFront)) && Input.GetKey(KeyCode.leftShift))
  41. {
  42. transform.Translate(0,0, walkSpeed * time.deltaTime);
  43. animations.Play("run");
  44. }
  45.  
  46. // si on recule
  47. if (Input.GetKey(InputBack))
  48. {
  49. transform.Translate(0, 0, -(walkSpeed / 2) * Time.deltaTime);
  50. Animations.Play("walk");
  51. }
  52.  
  53. // rotation à gauche
  54. if (Input.GetKey(inputLeft))
  55. {
  56. transform.Rotate(0, -turnspeed * Time.deltaTime, 0);
  57.  
  58. }
  59.  
  60. // rotation à droite
  61. if (Input.Getkey(inputRight))
  62. {
  63. transform.Rotate(0, turnSpeed * Time.deltaTime, 0);
  64.  
  65. }
  66.  
  67. }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement