Hi there, I am taking a simple sphere rigidbody and trying to make it hop up and move 1 vector to the right “Grid system”. It works, but the problem is its moving from the start position to “-1 in the X” instantly. I would like it to move within say 1 second from a to b. Is it because I’m putting it in function Update?
var start : Transform;
var end : Transform;
function Update ()
{ //Right
if (Input.GetKeyDown(KeyCode.RightArrow))
{
rigidbody.AddForce (Vector3.up * 100);
transform.position = Vector3.Lerp(start.position, end.position + Vector3(-1, 0, 0),Time.time);
}
}
use Time.deltaTime instead Time.time
if “Time” doesn’t work, just trying changing that variable to a float. I used something like “.2” in my code and that is really nice and smooth.
I just changed that to Time.deltaTime. Now it moves in tiny amounts to the right and it seems to ignore the addForce. I have a feeling I need more complex code. I basically want it to “hop” up and while its traveling in the air to slowly move 1 vector in the given direction.
You don’t want to use Update. See GridMove.
–Eric
Thanks everyone. esp for that link Eric. I guess ill study that and try to incorporate a little “hop” on the forward and right movements.
just a lil game I’m working on, could be fun.
You want simpler code, not more complex code.
Just found this AniMate. This seems like a workaround, I have managed to get more or less what I want with this, and a bit more tweaking and I should get it to how I want, I hope. I agree, simpler is better than complex, that’s how I like it, but I’m not that good with Unity yet and learning by trial and error. 