- Home /
Portions of code don't work in Monodevelop
I am making a 2D game and in the process of making a jumping script I noticed that I could use the "rigidbody2D.addforce" for it. When I began to test the code for errors, it said that "addforce" was not defined. Also, I am using unityscript for this.
Answer by Landern · Apr 14, 2015 at 01:18 PM
"rigidbody2D.addforce" is not a method of type Rigidbody2D
If you have a type RigidBody2D:
var rb:Rigidbody2D = GetComponent.<Rigidbody2D>();
and you want to invoke the method "AddForce", then case is explicit as shown in the link above.
you can now use the variable "rb" which is of type Rigidbody2D to invoke the method.
rb.AddForce(new Vector2(1, 2));
What your code, it is case sensitive.
Thank you! I didn't realize that! Anyhow, I'll try to incorporate that into my code!
Your answer
Follow this Question
Related Questions
AddTorque Isn't Working? 1 Answer
Adding an offset to an instantiated objects rotation 0 Answers
Combo Script Problem 1 Answer
Can I use Javascript (Unityscript) for Box2D for Unity or Farseer Physics? 1 Answer
Teleporting from one scene to another and back again with the same player gameobject 1 Answer