I'm trying to make a small program that control the movement of the player with C# project.
I want to access the variables of my class 'PlayerController' from the class 'PlayerController' but I keep getting this error: The left-hand side of an assignment must be a variable. Anyone can explain to me what am I am doing wrong here and how to avoid such mistake in the future?
Error:- [22:36:52) Assets\Scripts\PlayerController.cs(17,28): error CS0131: The left-hand side of an assignment must be a variable, property or indexer.
Script which I Used :-
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerController : MonoBehaviour
{
CharacterController characterController;
public float MovementSpeed = 1;
public float Gravity = 9.8f;
private float velocity = 0;
private void Start()
{
characterController = GetComponent<CharacterController>();
}
void Update()
{
// player movement - forward, backward, left, right
float horizontal = Input.GetAxis("Horizontal") * MovementSpeed;
float vertical = Input.GetAxis("Vertical") = MovementSpeed;
characterController.Move((transform.right * horizontal + transform.forward
* vertical) * Time.deltaTime);
// Gravity
if (characterController.isGrounded)
{
velocity = 0;
}
else
{
velocity -= Gravity * Time.deltaTime;
characterController.Move(new Vector3(0, velocity, 0));
}
}
}