Quantcast
Channel: Questions in topic: "error message"
Viewing all articles
Browse latest Browse all 2891

Assets\PlayerController.cs(29,29): error CS0200: Property or indexer 'Vector3.normalized' cannot be assigned to -- it is read only

$
0
0
I am rather new to coding and i was trying to code a game in unity. I was watching a video to see exactly how to do it and i did exactly what was shown in the video but i still got this error message: ***Assets\PlayerController.cs(29,29): error CS0200: Property or indexer 'Vector3.normalized' cannot be assigned to -- it is read only*** I tried tons of different things like changing the wording and completely removing it but nothing seemed to work. Here is the code: using System; using System.Collections.Specialized; using System.Security.Cryptography; using UnityEngine; [RequireComponent(typeof(PlayerMotor))] public class PlayerController : MonoBehaviour { [SerializeField] private float speed = 5f; private PlayerMotor motor; void Start () { motor = GetComponent(); } void Update () { //Calculate movement velocity as a 3D vector float _xMov = Input.GetAxisRaw("Horizontal"); float _zMov = Input.GetAxisRaw("Vertical"); Vector3 _movHorizontal = transform.right * _xMov; Vector3 _movVertical = transform.forward * _zMov; //Final movement vector Vector3 _velocity = (_movHorizontal + _movVertical).normalized = speed; //Apply movement motor.Move(_velocity); } } If you spot any other possible errors then please let me know.

Viewing all articles
Browse latest Browse all 2891

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>