Archived

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

ca_priest

npcs are moving faster than character at same velocity

Recommended Posts

My game is a 2D rpg. My problem is that although npc''s and the playable character both have the same walking velocities, the npc''s are still moving faster. Im curious as to why and how i can fix this. The animation is smooth for both the character and npc''s and no frames are skipped. I even tried putting 17 npc''s on the same screen walking around with the character but still, all the npc''s move at a constant speed that is a little bit faster than the character. The only thing i can think of is that maybe it has somthing to do with the rate im gathering user input, and maybe key presses are being missed? If that was the case however id expect some frames in the sequence of animation to skip and that isnt happening. Any ideas are appreciated.

Share this post


Link to post
Share on other sites
unlikely, if that were the case the NPCs speed would be some multiple of the players speed, which would be more than ''a little bit''. on the other hand, at low speeds 2x the speed could seem like a little bit, so it''s worth checking all the same....

Share this post


Link to post
Share on other sites
Well i checked to see if that was the problem, and that isnt it. I too thought that wouldve been unlikely because the npc would have to be moving at least twice as fast. Both the npc''s and the character are moving at one pixel per cycle, each cycle being 1/50th of a second, as the fps is 50. This makes for some realistic walking speed. Anyway, just by watching objects move it looks to me like the npc''s are moving between 45 and 55 pixels per second, theres absolutely no way they''re moving 100 pixels per second, which would be the minimum speed if they were being redrawn. Maybe its possible that the character is being redrawn every other frame...it looks to me like hes moving about 30-35 pixels per second. The only diffrence between npc''s and the character is the way they get what direction to move next, or what action to do next. NPC''s get it from the AI and the character gets it from the keyboard, so unless this speed diffrence has somthing to do with keyboard input, im completely stumped.

Share this post


Link to post
Share on other sites
Try logging to file this information: each frame, output "\n ", then "NPC " if the NPC is moving one pixel this frame, and "Char " if the PC is moving one pixel this frame. Then log any other information( keyboard input, etc..) based on the information you got from the log.

ToohrVyk
-------------
Extatica - a free 3d game engine
Available soon!
Click here to learn more

Share this post


Link to post
Share on other sites
are you using windows messages for input? that will make your program ''think'' its getting less key updates than it should. even still, that could be the cause with directinput or sdl if thats what you are using.

Share this post


Link to post
Share on other sites