# Do online games use functions to figure motionpath

2 replies to this topic

### #1 Keysle

Keysle

GMC Member

• GMC Member
• 208 posts

Posted 25 May 2012 - 07:48 AM

Here is a video of me explaining my concept. It's something I came up with to solidify the perception between client and server.

It's 13+ minutes long. So I'll do my best to explain it here as well.
In online game play, do shared objects of motion have a path that is based on a function (this function being defined upon the creation of the object considering the factors associated with motion; gravity, wind, weight, etc) as opposed to a path that is persistently being updated by re-applying the defined laws of physics every "step/moment/frame" during game play.

After some thought, I think this is the standard & most effective way of determining a path.
Here are two more videos expanding on the concept.

Let me know if my logic is off somewhere

The final additional video is about when NOT to use this method because the creation of the function is far too expensive in comparison to re-checking with the server just for 3 simple variables.
• 0

### #2 Jobo

Jobo

No neurons left today

• GMC Member
• 2404 posts
• Version:GM:Studio

Posted 25 May 2012 - 05:17 PM

In general, you never call a function unless it's absolutely critical that it's called.
In online games, you would normally send a packet every time an important factor to the movement changes.

For example, player starts moving in direction 90 and speed on 4. Send packet with direction and speed.
Now the player stops moving, so speed is set to 0. Send packet with speed.
Player starts moving in another direction. Send packet with direction and speed.

But this is not pathfinding, only the appropriate times to send a packet.
If you're using a path, your client is usually capable of handling the movement and collision checking etc on its own.
And since the all clients have the same output as each other, simply define the path on creation and send it to all the packets.
Then each client will handle the movement from there on equally, as they all have the same environment.
This is assuming you want a pre-defined path, and not a constantly updating path.
If you have a constantly updating path, send a packet to all other clients (except self) every time the path makes a significant change.

I did not watch the videos, but I hope this will clarify some aspects for you.
• 0

### #3 Keysle

Keysle

GMC Member

• GMC Member
• 208 posts

Posted 25 May 2012 - 09:44 PM

Yes. This is essentially what I thought was the case. When I say "function" i mean mathematical function that determines the path of an object.
That math function can come in the form of a string "x=cos(t)*10;y=sin(t)*10"
the path would be a circle. (I wouldn't advise using strings. probably as set of nested/branching nodes to define nomials and their inner operations.
• 0

#### 0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users