Game Development Community

How would I code jerky movements instead of floating into iTorque? (will my current plan work?)

by Adam Emrick · in iTorque 2D · 11/02/2011 (12:50 am) · 3 replies

My goal is to make my animated sprite (an insect) move around with jerky movements. I want to make it like each frame of the animation is
stepping forward. I want to also randomly change the speed.

Would it be correct to assume in order to move the insect object forward suddenly (like an insect does, jerky rather than floating) I have
to manipulate the setPosition(float x, float y) of the object on each frame?

If conceptually this seems viable, I was thinking I might start by manually moving the position on the changeframe event/callback.
I figured I'd also change the speed here, but only when a period of time had elapsed. (say randomly between 3-10 seconds, the speed changes)If i were coding in another language, i'd put a timestamp in a variable, then check back on the timestamp on each frame itteration.

Seem do-able?

Thanks for any help!

#1
11/02/2011 (8:58 am)
I would perhaps, like you say on random...


so somtheing like....


function moveSprite()
{
%jerk = getRandom(0, 1);

if(%jerk == 0)
///move smoothly
if(%jerk ==1)
///move jerkily

}

I would suggest vastly different velocities. and that is move jerkily is true, it can only last for a snap shot.







#2
11/02/2011 (1:18 pm)
I think you will get a better result if you made actual animations of the insects moving in a jerky manner and played through those frames, swapping out every now and then to different frame sets. I think you will spend less time trying to perfect it in code and you (or your gfx artists) will have a much shorted feedback loop whilst you perfect the movements.
#3
11/02/2011 (1:32 pm)
I agree with scott. My example has more to do with velocity. This (my example - keeping in mind you could o there things like "widen the random possibilities - not just 50/50 and if x value hit, make jerky, play jerky animation).

It can be done tho. quite easily.

Velocity, comes into it tho, for me and if you are thinking that when jerky, a high speed "sprint" for less then a second then it is cut off to be setAtRest().