Archived

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

eldee

Projectile Trajectory tracking- is my method bad for online gaming?

Recommended Posts

howdy.. i''ve got a 2D side view wargame im working on, and i''m using a really simple method for angular trajectories.. to update a projectile, i just add it''s x and y velocities to it''s x and y positions each frame. my problem is this: ive always wanted to make this an online game, and im starting to think that my simplistic method would be bad for online gaming- ie) if a player has a slower machine, his projectiles would update less.. i was beginning to think that i can probably factor in the elapsed cycle time and go from there, but i didnt want to spend too much time on it if its'' a bad idea. anybody have any suggestions for angular trajectories in online multiplayer games? keep in mind that it''s side view 2D (ala worms/mario/ect). any feedback is appreciated -eldee ;another space monkey; [ Forced Evolution Studios ]

::evolve::

Share this post


Link to post
Share on other sites
Haven''t done much of that stuff myself, but I''m pretty sure that the first thing to do is to have the current position of the projectile as a function of the initial vector, velocity and time, and the time elapsed since then. I won''t give you the formula for this, but it should be in most physics books.

When you have your code like that, the step will be smaller when it comes to network playing and prediction.

Share this post


Link to post
Share on other sites
yea i tried a few calc functions and none seemed to
work right.. probably because im not implementing them right,
but i used something to the effect of
XPosition += XVelocity * time_elapsed + (0.5 * WindResistance * time_elapsed * time_elapsed )
YPosition += YVelocity * time_elapsed + (0.5 * Gravity * time_elapsed * time_elapsed

in theory i'd think that should do the trick, but i havent
been able to get it to work

-eldee
;another space monkey;
[ Forced Evolution Studios ]


::evolve::

[edited by - eldee on August 31, 2002 7:12:50 PM]

Share this post


Link to post
Share on other sites
Sorry, I''m very poor at the moment when it comes to orbits etc; someone else need to take on that. How is your current, incremental, formula? If that one works, it should be a piece of cake to convert it.

I haven''t studied the formula you gave, but it should be something like this:

XPositionCur = XPositionOrig + XVelocity * time_elapsed + (0.5 * WindResistance * time_elapsed * time_elapsed);
YPositionCur = YPositionOrig + YVelocity * time_elapsed + (0.5 * Gravity * time_elapsed * time_elapsed);

Where [X|Y]PositionOrig is the launch point, or where it was on relative time Zero. time_elapsed is then the relative time since the launch.

Share this post


Link to post
Share on other sites
Use your technique to predict the future position of the bullet, but not to know it. The only way you can know its position is to fetch it from the server. In other words:


    
//PSEUDOCODE

if(theServerSentYouThePositionOfTheBulletThisFrame)
{
bullet.position = serverdata.bullet.position
}
else
{
bullet.position += bullet.velocity / FPS;
}


That, at least, is essentially the way it works in Quake and its ilk.

[edited by - TerranFury on August 31, 2002 8:56:23 PM]

Share this post


Link to post
Share on other sites
quote:
Original post by CWizard
Sorry, I''m very poor at the moment when it comes to orbits etc; someone else need to take on that. How is your current, incremental, formula? If that one works, it should be a piece of cake to convert it.

I haven''t studied the formula you gave, but it should be something like this:

XPositionCur = XPositionOrig + XVelocity * time_elapsed + (0.5 * WindResistance * time_elapsed * time_elapsed);
YPositionCur = YPositionOrig + YVelocity * time_elapsed + (0.5 * Gravity * time_elapsed * time_elapsed);

Where [X|Y]PositionOrig is the launch point, or where it was on relative time Zero. time_elapsed is then the relative time since the launch.



ah, that might''ve been where i screwed up.. instead of using
the original position, i''ve been using the current position
makes alot more sense now.. lemme go see if that works ;P




-eldee
;another space monkey;
[ Forced Evolution Studios ]


::evolve::

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Does the projectiles attributes ever change after it is fired? If not, there is no need to constantly update the the position of it over the network, as you can just send a message when it is fired (and send another when it hits an object/dissappears etc.), with all the attributes neccessary, and the client can update the position itself. If you''re worried about projectiles being in different positions ebcause of different framerates, then you should do all your clients position updates as a function of time, so that no matter how many frames per second a machine is running at, the speed is always the same.

Share this post


Link to post
Share on other sites