Showing posts with label Unity3D. Show all posts
Showing posts with label Unity3D. Show all posts

Thursday, November 6, 2014

Cannot modify a value type return value of `UnityEngine.Rigidbody2D.velocity'. Consider storing the value in a temporary variable



Unity Sample Code :

rigidbody2D.velocity.y = speed;

The above C# code won't show any syntax error. But unity 4 and above will throw runtime error saying

"Cannot modify a value type return value of `UnityEngine.Rigidbody2D.velocity'. Consider storing the value in a temporary variable"