M
M
MorsMors2020-04-30 17:11:02
C++ / C#
MorsMors, 2020-04-30 17:11:02

How to fix error CS0019?

The + operator cannot be assigned to Vector2
This code used to work, but it also stopped please help.
public float speed=20f;
private Rigidbody2D Rb { get; }
private Vector2 Vector2 { get; }
void Start()
{
_ = Rb == GetComponent();
}

void Update()
{

float moveX = Input.GetAxis("Horizontal");
object p = Rb.MovePosition(Rb.MovePosition + (Vector2.right * moveX * speed * Time.deltaTime)); // error

}
}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
#
#, 2020-04-30
@MorsMors

and the method does not return anything. see
docs https://docs.unity3d.com/ScriptReference/Rigidbody...

This code used to work
he could not work exactly in this form
!!! note - wrap the code in the codesite rules requirement tag, and it's easier to read
ps advice - add the tag Unityto the question onUnity

T
Timur Pokrovsky, 2020-04-30
@Makaroshka007

Did you give the Vector2 class object the name Vector2?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question