I’m pretty new to this, and actually almost completely new to javascript, but I’m trying to learn through experience and I’m already having trouble. A day ago I’d gotten AddForce to work properly in CSharp, but I’ve changed my mind and decided to go through javascript instead, and I can’t really get it to work. I was watching some videos earlier today and they said it was a good idea to cache a function for optimization, so I wrote it exactly how they did. Here’s my script:
#pragma strict
private var MyRig = Rigidbody;
function Start () {
}
function FixedUpdate () {
var balljump = Input.GetKeyDown(KeyCode.Space);
if(balljump){
MyRig.AddForce(transform.up * 50);
}
}
I’ve tried rewriting it to exclude the variable cache, and it still didn’t work. The error I keep getting is:
Assets/Scripts/Ballcontrol.js(13,7): BCE0019: ‘AddForce’ is not a member of ‘System.Type’.