|
So I don't know what I'm missing but I can't get this to work. I basically need an object to jump every so often. Here's my code: var power : float = 500.0; The counter won't go up when I run it. I tried counter++ and that didn't work either. Any help is appreciated!
(comments are locked)
|
|
As @BiG said, update isn't the same thing as Update - you should fix the function name (it's Update).
var jumpInterval: float = 1.0; // interval between jumps in seconds
var power : float = 500.0;
private var timeToJump: float = 0.0;
function Update () {
if (Time.time >= timeToJump){
rigidbody.AddForce(Vector3(0,power,0));
timeToJump = Time.time+jumpInterval;
}
}
Also knew it was a clumsy script, all mine are. Thanks for a better one!
Apr 25 '12 at 09:41 PM
Draspur
(comments are locked)
|
|
function Update, not function update. This way, you have not declared a function that will be executed each frame, but a function that will never be executed :) Knew it was something silly like that, thanks! Sorry for late reply.
Apr 25 '12 at 09:40 PM
Draspur
(comments are locked)
|
|
If you use this code, the amount of time between jumps will vary depending on the game's current FPS; that's usually not a desired behavior. You might instead consider using
(comments are locked)
|
|
it should work as : But because it's not, I have no idea sorry.
(comments are locked)
|
