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.
Can anyone perhaps give some adivce for this? Thanks.
About the author
#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
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.
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
One small question though is on the second step. -Add entry to Player::InitPersistFields() There is no Player::InitPersistFields(), did you mean PlayerData?
Thanks.
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.
Torque Owner Eric Hartman
You need to send the new mass value to the clients via a ::packUpdate somewhere.