Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.AI;
- [ExecuteInEditMode]
- public class PlayerMovement : MonoBehaviour {
- private Transform transform;
- private Animator anim;
- // Use this for initialization
- void Start () {
- transform = GetComponent<Transform>();
- anim = GetComponent<Animator>();
- }
- private void Update()
- {
- float vertical = Input.GetAxis("Vertical");
- float horizontal = Input.GetAxis("Horizontal");
- if (Input.GetKey(KeyCode.W))
- {
- anim.SetBool("IsMoving", true);
- transform.Translate(transform.rotation.x, 0, .1f);
- }
- if (Input.GetKeyUp(KeyCode.W))
- {
- anim.SetBool("IsMoving", false);
- }
- if (Input.GetKey(KeyCode.D))
- {
- transform.Rotate(0, 2.5f, 0);
- } else if (Input.GetKey(KeyCode.A))
- {
- transform.Rotate(0, -2.5f, 0);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement