Game Development Community

Updating Player Mass

by Jacob Dankovchik · in Torque Game Engine · 07/11/2005 (6:09 am) · 5 replies

I currently am in need of updating the mass of the player so his physics are effected. I tried this by adding mass to the datablock value and then calling a function in the engine, updateMass. This works fine however for some reason when the player is speeding up or slowing down, the camera gets extremely jittery. The more mass I add, the worse it gets. If i set the mass to a very high level in the datablock before had, it is smooth. It only gets jittery when I add mass, not when its at a high level.

Can anyone perhaps give some adivce for this? Thanks.

#1
07/11/2005 (6:20 am)
The jittering occurs because the client side prediction is getting out of sync with the server. The client is still using the original mass value and so it can't accurately predict where the player is supposed to go.

You need to send the new mass value to the clients via a ::packUpdate somewhere.
#2
07/11/2005 (6:27 am)
I figured that's what it may be.. But how exactly do I do that? I'm not too familiar with that stuff in the engine..
#3
07/11/2005 (6:53 am)
Heres a basic outline of what you need to do:

Add a mass field to the Player class
-Change player.h
-Add entry to Player::InitPersistFields()
-Initialize value from datablock in ::onAdd
Change player physics code so that it uses the player's mass instead of the PlayerData's mass
Add a new bitmask to the Player Class named PhysicsMask (or whatever you want)
Add function Player::SetMass and a connect it to the console with ConsoleMethod()
-In this function, assign the new mass value and do a setMaskBits(PhysicsMask);
Change Player::packUpdate and ::unpackUpdate to transmit the mass value
-Check for the physics mask with something like this if(stream->writeFlag(mask & PhysicsMask))

Tell me which parts you're not clear on and I can give you more detail when i get home this evening.
#4
07/11/2005 (7:10 am)
Hm.. I think i got most of that... I'll try messin around in a bit, see if I understand it as much as I think..

One small question though is on the second step. -Add entry to Player::InitPersistFields() There is no Player::InitPersistFields(), did you mean PlayerData?

Thanks.
#5
07/11/2005 (7:34 am)
Scratch that, you dont need the initpersist entry at all.