Follow Object With Transition

I wanted to know how I can get an object that is spawned to follow another object using the transition library and then have it stop a bit behind the object. Note: i am controlling the object that needs to be followed with a joystick, and am basically trying to make the behavior of a snake.

Heres what i thought:

transition.to(body{time=300, x=snake.x-distance, y= snake.y-distance, rotation=snake.rotation})

only problem is it follows for 300 milliseconds like i told it to and then stops, and even if i try the loop method, it still doesn’t want to run.

Thanks

Hi @gamelibrary,

Are you planning to use the physics engine for your game? If so, a nice way to accomplish this is with physics joints. This is especially true if you want to have a multi-segment “snake” object with many parts linked together.

Best of luck,

Brent Sorrentino

yes, i was trying to do this with physics and joints, however, when more “parts” of the snake are added, the snake slows down as if the weight of the parts are dragging it, even when I have density set to 0 on them.

What kind of joints are you using? Depending on the joint type, you may need to adjust the parameters of them (the joints) to make them more rigid.

Brent

i found rope joint to work best, distance is the second.

On the distance joint, try adjusting the “frequency” and “dampingRatio”. Much of this is referenced here:

http://developer.coronalabs.com/content/game-edition-physics-joints

Thanks for your response.

Hi @gamelibrary,

Are you planning to use the physics engine for your game? If so, a nice way to accomplish this is with physics joints. This is especially true if you want to have a multi-segment “snake” object with many parts linked together.

Best of luck,

Brent Sorrentino

yes, i was trying to do this with physics and joints, however, when more “parts” of the snake are added, the snake slows down as if the weight of the parts are dragging it, even when I have density set to 0 on them.

What kind of joints are you using? Depending on the joint type, you may need to adjust the parameters of them (the joints) to make them more rigid.

Brent

i found rope joint to work best, distance is the second.

On the distance joint, try adjusting the “frequency” and “dampingRatio”. Much of this is referenced here:

http://developer.coronalabs.com/content/game-edition-physics-joints

Thanks for your response.