Hello. I am writing a fairly simple game like fps shooter. Faced a problem, namely:
Vector3 mov_horizontal = transform.right = xMov; Vector3 mov_vertical = transform.forward = zMov; The compiler swears at xMov && zMov, writes:
Cannot implicitly convert type "float" to "UnityEngine.vector3"
Who to share a possible solution to this problem.
All code:
using UnityEngine; [RequireComponent(typeof(PlaerModer))] public class PlaerControiler : MonoBehaviour { [SerializeField] private float speed = 5f; private PlaerModer motor; private void Start() { motor = GetComponent<PlaerModer>(); } private void Update() { float xMov = Input.GetAxisRaw("Horizontal"); float zMov = Input.GetAxisRaw("Vertical"); //Ошибка здесь Vector3 mov_horizontal = transform.right = xMov; Vector3 mov_vertical = transform.forward = zMov; Vector3 velocity = (mov_horizontal + mov_vertical).normalized * speed; motor.Move(velocity); } } 