Hi!
I’ve made this VERY simple player script and I need the Vector3. to react the current rotation of the player.
My script:
using UnityEngine;
using System.Collections;
public class PlayerController : MonoBehaviour {
public float speed;
Animator anim;
void Start () {
anim = GetComponentInChildren<Animator> ();
//anim.SetBool ("Run", false);
anim.SetBool ("Aim", false);
}
// Update is called once per frame
void Update () {
if (Input.GetButton ("Forward")) {
transform.position += Vector3.forward * Time.deltaTime * speed;
anim.SetBool("RunForward", true);
anim.SetBool("RunBackwards", false);
anim.SetBool("RunRight", false);
anim.SetBool("RunLeft", false);
} else if(Input.GetButton("Left")){
transform.position += Vector3.left * Time.deltaTime * speed;
anim.SetBool("RunForward", false);
anim.SetBool("RunBackwards", false);
anim.SetBool("RunRight", false);
anim.SetBool("RunLeft", true);
} else if(Input.GetButton("Backwards")){
transform.position += Vector3.back * Time.deltaTime * speed;
anim.SetBool("RunForward", false);
anim.SetBool("RunBackwards", true);
anim.SetBool("RunRight", false);
anim.SetBool("RunLeft", false);
} else if(Input.GetButton("Right")){
transform.position += Vector3.right * Time.deltaTime * speed;
anim.SetBool("RunForward", false);
anim.SetBool("RunBackwards", false);
anim.SetBool("RunRight", true);
anim.SetBool("RunLeft", false);
} else {
anim.SetBool("RunForward", false);
anim.SetBool("RunBackwards", false);
anim.SetBool("RunRight", false);
anim.SetBool("RunLeft", false);
}
}
}
If you know what to do, please tell me!
Thanks