This question was
closed Mar 29, 2017 at 05:35 AM by
RonnieThePotatoDEV for the following reason:
The question is answered, right answer was accepted
Question by
RonnieThePotatoDEV · Mar 29, 2017 at 05:23 AM ·
c#errormovementvector2
[C#] The left-hand side of an assignment must be a variable, a property or an indexer
First off, I know there are a lot of questions regarding this error, but it seems that the error can come from different situations.
Hello everybody, I am trying to make a simple pong game. I have my script for moving the paddles, which worked fine. However I want the paddles to stop moving when I let go of the up and down keys. In my attempt of doing so, I added lines 22 - 25 in the code below (everything was working fine before I added these.) I get the error: "The left-hand side of an assignment must be a variable, a property or an indexer."
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Player1_Movement : MonoBehaviour {
public float PlayerSpeed = 2;
private Rigidbody2D rb;
private Vector2 Movement;
void Start()
{
rb = GetComponent<Rigidbody2D> ();
Movement = GetComponent<Vector2> ();
}
void FixedUpdate ()
{
float Vertical = Input.GetAxis ("Vertical") * PlayerSpeed;
Vector2 Movement = new Vector2 (0, Vertical);
if (Input.GetAxis("Vertical") = 0)
{
rb.AddForce(Movement);
}
rb.AddForce (Movement);
}
}
Thanks for the help!
Comment