Because this feature is new I can find any guides online on how to use it.
The scripting reference has:
AddForce(force: Vector2): void;
What parts of this am I meant to change?
just using this code in my script
function FixedUpdate ()
{
if(Input.GetKey ("d"))
{
AddForce(force: Vector2): void;
}
}
gives the errors:
“Assets/My script/Move.js(6,26): BCE0043: Unexpected token: force.”
“Assets/My script/Move.js(6,41): BCE0043: Unexpected token: :.”
“Assets/My script/Move.js(6,42): UCE0001: ‘;’ expected. Insert a semicolon at the end.”
How do I use this?
Thanks, why don't they have example code in the scripting reference?
– qwertyk31I just tested this and now I get "Assets/My script/Move.js(6,17): BCE0005: Unknown identifier: 'AddForce'."
– qwertyk31I guess they either missed it, trying to update documentation pages for new 4.3 classes, or maybe they just decided that sample is not required in this case. There are more pages in official docs, that lack examples.
– ArkaneXYou have to call this method on actual Rigidbody2D instance. Answer updated.
– ArkaneXnew code gives me "Assets/My script/Move.js(7,17): BCE0004: Ambiguous reference 'rigidbody2D': Move.rigidbody2D, UnityEngine.Component.rigidbody2D."
– qwertyk31