Advertisement
Guest User

Untitled

a guest
Dec 5th, 2016
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. public class Hero : MonoBehaviour
  2.  
  3. // Use this for initialization
  4. void Start()
  5. {
  6.  
  7.  
  8. hero = gameObject.GetComponent<CharacterController>();
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15. }
  16.  
  17. // Update is called once per frame
  18. void Update()
  19. {
  20. Vector3 moveDirection = Vector3.zero;
  21.  
  22. if (hero.isGrounded)
  23. {
  24. moveDirection = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
  25. moveDirection = transform.TransformDirection(moveDirection);
  26. moveDirection *= speed;
  27.  
  28. // раскоментировать для прыжка
  29. // if (Input.GetButton("Jump"))
  30. // moveDirection.y = jumpSpeed;
  31.  
  32. }
  33. moveDirection.y -= gravity * Time.deltaTime;
  34. hero.Move(moveDirection * Time.deltaTime);
  35.  
  36. if (Input.GetKey(KeyCode.A))
  37. {
  38. for (int i=0;i<tree.Length;i++)
  39. {
  40. var p= tree[i].GetComponent<Animation>();
  41. p.AddClip( NewAnimationn,"TimeLapse");
  42. p.Play();
  43.  
  44.  
  45. }
  46. }
  47. }
  48.  
  49. GameObject[] tree = GameObject.FindGameObjectsWithTag("tree");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement