Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class MovePlayer : MonoBehaviour
- {
- public float moveSpeed = 20f;
- public float turnSpeed = 0;
- public GameObject Player;
- public Animator Player_Animation;
- public bool run = false;
- public bool front =true ;
- public bool back = false;
- void Start()
- {
- Player_Animation = Player.GetComponent<Animator>();
- }
- void turnLeft()
- {
- if (front == true)
- {
- Player.transform.Rotate(Vector3.up, 180);
- }
- }
- void TurnRight()
- {
- if (back == true)
- {
- Player.transform.Rotate(Vector3.up, -180);
- }
- }
- void Update ()
- {
- if(Input.GetKey(KeyCode.D) && run == false )
- {
- transform.Translate(Vector3.forward/2 * moveSpeed * Time.deltaTime);
- Player_Animation.SetBool("Walk",true);
- turnLeft();
- }
- else
- {
- Player_Animation.SetBool("Walk",false);
- }
- if(Input.GetKey(KeyCode.A))
- {
- transform.Translate(-Vector3.forward * moveSpeed/2 * Time.deltaTime);
- Player_Animation.SetBool("BackTurn",true);
- TurnRight();
- // TeamKum_Animation.SetBool("Back",true);
- }
- else
- {
- Player_Animation.SetBool("BackTurn",false);
- // TeamKum_Animation.SetBool("Back",false);
- }
- if(Input.GetKey(KeyCode.G))
- {
- transform.Rotate(Vector3.up, -turnSpeed * Time.deltaTime);
- Player_Animation.SetBool("Atack1",true);
- }
- else
- {
- Player_Animation.SetBool("Atack1",false);
- }
- if(Input.GetKey(KeyCode.RightArrow))
- {
- transform.Rotate(Vector3.up, turnSpeed * Time.deltaTime);
- // TeamKum_Animation.SetBool("Right",true);
- }
- else
- {
- // TeamKum_Animation.SetBool("Right",false);
- }
- if (Input.GetKey(KeyCode.Space))
- {
- Player_Animation.SetBool("Jump",true);
- }
- else
- {
- Player_Animation.SetBool("Jump",false);
- }
- if (Input.GetKey(KeyCode.LeftShift))
- {
- moveSpeed = 45f;
- transform.Translate(Vector3.forward/2 * moveSpeed * Time.deltaTime);
- Player_Animation.SetBool("Run",true);
- run = true;
- }
- else
- {
- moveSpeed = 20f;
- Player_Animation.SetBool("Run",false);
- run = false;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement