TGB 1.7.3 beta Forward Only in Physics (Potential Bug)
by Dustin Sims · in Torque Game Builder · 05/15/2008 (6:34 am) · 1 replies
I have an object with the Forward Only Box in the Physics rollout checked.
That object has Circle Collision Detection Mode and Clamp Response.
Send and Receive Collisions are on.
My object is rotated 180 deg. so that I can have it's Y Velocity and Constant force make it "Fall" down the screen.
The problem is... When it hits another object, it will still start moving in the X direction.
The Forward Only box states:
"Allows the object to only move in it's forward direction"
It does seem to work properly if the object has it's Collision Response set to Sticky.
It will stop and then not continue to move in the X direction.
I would think that the Forward Only would not allow X movement no matter what the Collsion Response was set to.
That object has Circle Collision Detection Mode and Clamp Response.
Send and Receive Collisions are on.
My object is rotated 180 deg. so that I can have it's Y Velocity and Constant force make it "Fall" down the screen.
The problem is... When it hits another object, it will still start moving in the X direction.
The Forward Only box states:
"Allows the object to only move in it's forward direction"
It does seem to work properly if the object has it's Collision Response set to Sticky.
It will stop and then not continue to move in the X direction.
I would think that the Forward Only would not allow X movement no matter what the Collsion Response was set to.
Associate Melv May
Note though that when an object is set as forward only, it cannot be correctly solved by collison responses other than sticky. For instance, if your use bounce, the collision response has to rotate the object so that it can correctly bounce away. Should it do this? Should it rotate instantly? Add parameters to the bounce-response for this? All this adds complexity and this kind of edge-case behaviour would slow things down.
The forward only was requested a while ago after the major parts of the collision system were implemented. It was primarily asked for so that people could do top-down vehicle or missile-style movement. When using this function you cannot correctly rely on the internal collision response unless you're doing something simple like stopping the object.
You also can't apply constant directional velocity. This is because all energy given to the object in terms of momentum will be used to move in the "forward" direction. You can use constant velocity / damping but the actual velocity will be applied in the forward-only direction.
If you want to check for collisions you can either use the internal collision detection and hook into the "onCollision()" callback and do your own response (which is simple) or turn-off the internal collision detection and use the "castCollision(List)" or picking functions to check for collisions and again, determine what the collision response should be.
Missiles may just explode but vehicles may want to bounce directly back slightly to allow the player room to turn in the correct direction. There's just no way TGB can continue adding game-specific behaviour like this into the collision response.
It's a very cool feature but you need to take a certainly level of control on board yourself with it.
You may have encountered some kind of bug though and I'm not sure I fully understand the problem you're seeing so if you could send me your script package so I can see it for myself then I can give you something more useful quicker.
Cheers,
Melv.