Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.



This topic is 5911 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am trying to create a snake-like creature. The idea here is that the snake can move around on the landscape, and look more or less natural (i.e. if you turn in a circle, its body forms a circle, if you move in a straight line, it forms a line, if you get mouse-frantic you could draw an S). The problem is that I just can''t get the body segments to move along properly. I''m now trying to use a Lerp, where each body segment is lerped between its current position and the position of the body part one step closer to the head, and it seems to be ok, except when I do really tight turns (sometimes the body parts don''t move... I''m guessing because the distance between two segments is already within the lerp range). Anyway, if someone has a better way of creating a snake, or of perhaps explaining the lerp thingy''s S parameter a bit better, it would be great. Other methods I have tried: Move This Segment to Higher Segment''s last position in the previous frame: - Causes gaps because the max movement distance can be greater than the size of a segment. Move Current Segment Towards Higher Segment''s Current Position:- gets a bit hectic on the maths because you have to figure out the angles that each segment is facing and then move it in that direction. Plus it creates some unusual movement physics because rear segments can just bypass the chain and move directly forwards... and I''m not trying to make a sidewinder

Share this post

Link to post
Share on other sites
hi, i used D3DXVec3Lerp, and here is what i understand of the S parameter, it is the offset of the interpolation from your first vector.
Try to look at it this way if you where trying to move obj a from point p1 to point p2 for a certain time unit let say 10. if you wanted to see the position of the object between p1 and p2 for example at time unit 5. 5 would be it''s offset from the first vector...

just remember that the S parameter only takes value from 0 to 1. so you must do a little math here

here is my code for the S parameter..

s = (float)(currentframe_no - left->frame_no)
/((right->frame_no - left->frame_no) * 1.0f);

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!