using System.Collections;
using UnityEngine;
public class ff : MonoBehaviour {
public Animator anim;
public Rigidbody rbody;
private float inputH;
private float inputV;
private bool run;
float rotSpeed = 80;
float rot = 0f;
// Start is called before the first frame update
void Start()
{
anim = GetComponent<Animator>();
rbody = GetComponent<Rigidbody>();
run = false;
}
// Update is called once per frame
void Update()
{
if(Input.GetKey(KeyCode.LeftShift))
{
run = true;
}
else
{
run = false;
}
if(Input.GetKey(KeyCode.Space))
{
anim.SetBool("Jump",true);
}
else
{
anim.SetBool("Jump",false);
}
inputH = Input.GetAxis ("Horizontal");
inputV = Input.GetAxis ("Vertical");
anim.SetFloat("inputH",inputH);
anim.SetFloat("inputV",inputV);
anim.SetBool ("run",run);
float moveX = inputH*60f*Time.deltaTime;
float moveZ = inputV*100f*Time.deltaTime;
if(moveZ <= 0f)
{
moveX = 0f;
}
else if (run)
{
moveX*=3f;
moveZ*=3f;
}
rbody.velocity = new Vector3(moveX,0f,moveZ);
rot += Input.GetAxis ("Horizontal") * rotSpeed * Time.deltaTime;
transform.eulerAngles = new Vector3 (0, rot, 0);
}
}