this.GetComponent<Rigidbody2D>().velocity compiler error

When I try and use

this.GetComponent<Rigidbody2D>(2f, 10f).velocity

in Unity 5 it gives me a compiler error that says, “Assets/Scripts/Ball.cs(23,9): error CS0201: Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement”.

Please correct me if I just typed the code wrong.


1 Like

Found it.
LuisFilipePires commented on 592c3d6 on Apr 28, 2017 •

this.GetComponent<Rigidbody2D>().velocity = new Vector2(2f, 10f)
1 Like

Hi,

Glad you managed to resolve the issue, please be aware that if you use < > characters in your posts the forum will assume they are markup, as such, they will no be displayed, this can be quite challenging for others when they try to help you.

Please use code formatting when copy/pasting code into your posts, I’ve updated the above two for you :slight_smile:


See also;

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms