Jump to content
  • Advertisement

Archived

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

onnel

Real time grid based movement

This topic is 6350 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''m working on a system that uses pausable realtime on a grid based system (XCOM IV-like is probably the best analogy). Can anyone make any recommendations for how to make this look smooth. I.e., I don''t want a character to just run in place at the center of a square and then suddenly pop into the center of the square he was running to. I want the movement to appear smooth so that the user might not be aware that there was even a grid being used. Any ideas for this? Is it possible to keep the smoothness while still using a grid based system? Onnel

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster

Just keep track of finer positionion in your character class. Use float (or fixed point if you like that sort of thing) instead of int for keeping track of his grid position. Then just interpolate his position over however many frames a move/walk sequence is.

So, his position over time, if moving from 2,2 to 2,3, would look like:


t=0 p=(2.0, 2.0)
t=1 p=(2.0, 2.2)
t=2 p=(2.0, 2.4)
t=3 p=(2.0, 2.6)
t=4 p=(2.0, 2.8)
t=5 p=(2.0, 3.0)


Or am I misunderstanding the question?




Share this post


Link to post
Share on other sites
Yeah I agree interpolate it so you move the sprite or whatever so much so many frames or if you want a cheap fix and movement like they did in Final Fantasy such as character moves one tile at a time you could if you have something like 32 x 32 height and width for each tile (psuedo code)
  

if(player.time_to_update)
if(player.x % 32) // not fully on a tile in processing of moving

player.x+=2;
else do whatever player is on tile waiting

Also the post above has a good way of doing it too keeping track that is but I''ve never really played xcom that much so I''m probably missing the question oh well no harm in posting

Share this post


Link to post
Share on other sites
Thanks for the replies. good info and it should work perfectly. I had something like that in mind and just wanted to make sure I wasn''t missing a better way.

Thanks!

Onnel

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!