Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Hero : MonoBehaviour
- // Use this for initialization
- void Start()
- {
- hero = gameObject.GetComponent<CharacterController>();
- }
- // Update is called once per frame
- void Update()
- {
- Vector3 moveDirection = Vector3.zero;
- if (hero.isGrounded)
- {
- moveDirection = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
- moveDirection = transform.TransformDirection(moveDirection);
- moveDirection *= speed;
- // раскоментировать для прыжка
- // if (Input.GetButton("Jump"))
- // moveDirection.y = jumpSpeed;
- }
- moveDirection.y -= gravity * Time.deltaTime;
- hero.Move(moveDirection * Time.deltaTime);
- if (Input.GetKey(KeyCode.A))
- {
- for (int i=0;i<tree.Length;i++)
- {
- var p= tree[i].GetComponent<Animation>();
- p.AddClip( NewAnimationn,"TimeLapse");
- p.Play();
- }
- }
- }
- GameObject[] tree = GameObject.FindGameObjectsWithTag("tree");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement