Gravity vector (directional gravity)
by J. Alan Atherton · in Torque Game Engine · 06/03/2003 (10:53 pm) · 5 replies
Got an interesting question... I added a gravity vector member to Player (I want gravity to be directional). Then I exposed it to the console. I changed the appropriate things in updateMove (where it adds gravity to the acceleration). It works as expected from the start (i.e. the player falls sideways instead of down), but when I change the vector via script, the gravity doesn't change. The values of my newly added gravity variable change, but it seems they have no effect. The acc variable inside updateMove (which accumulates all the various forces) even changes, showing the gravity has changed. But still, my player falls in the same direction as at first (sideways instead of up, like I changed it). Any help?
#2
06/03/2003 (11:12 pm)
Wow it must be late. Totally forgot the netcode (grrrr). Thanks for pointing out the obvious. Much appreciated. (The speedy reply too).
#3
That is just inside the Player constructor (probably not the right place). All I need is for this gravity to be scriptable and dynamic. Thanks for help!
06/03/2003 (11:55 pm)
Well, I added all the netcode, and it's still not working... dunno what's wrong. This got me thinking... there's got to be a better way to do this... my idea with this is to more or less mimic Marble Blast's gravity change powerups... where the gravity direction changes when the player hits a trigger. There will also be times that I'll want to change the gravity based on the player's position. Can I do this from GameConnection somewhere? As it was, the default player gravity is done inside Player::updateMove. It seems that I can't get this to script though. Which is rather necessary for my game... maybe it's the way I exposed the console variable? Here it is:Con::addVariable("mGravVec", TypePoint3F, &mGravVec);That is just inside the Player constructor (probably not the right place). All I need is for this gravity to be scriptable and dynamic. Thanks for help!
#4
06/04/2003 (12:07 am)
Er, to continue this monologue, I just remembered about a Dynamic gravity resource (no directional gravity, but that's a minor discrepancy). I should be able to adapt to all of that. If you're still reading this and feel like you should give some advice, go on ahead.
#5
In the engine allot of assumptions are made about items and players always being straight up (from what I've seen that is.)
and while just accelerating in a certain direction or towards a certain point is all fine and dandy... the main issue I think would actually showing that the object concider the direction of gravity 'down' and thus orient towards it and collide/ be able to move/act accordingly.
06/04/2003 (1:16 am)
I've been thinking about this myself... vector gravity, point gravity... and it all ain't that hard to get the acceleration correct... however orienting the objects (especially the player) correctly is what I'm worried about.In the engine allot of assumptions are made about items and players always being straight up (from what I've seen that is.)
and while just accelerating in a certain direction or towards a certain point is all fine and dandy... the main issue I think would actually showing that the object concider the direction of gravity 'down' and thus orient towards it and collide/ be able to move/act accordingly.
Torque Owner Dylan Sale
mmm Or you could add setMaskBits(GravUpdate) in the method that updates the gravity direction for the player (but youd need to add GravUpdate in the header with MoveMask etc), then you could just add it to the packUpdate method.
Hope you can understand this ;)