Game Development Community

Balance

by Victor Tan · in Torque Game Builder · 05/30/2007 (8:04 am) · 5 replies

I would like to have a pole to balance on a circle or a triangle, and if imbalance, the pole will fall over. The only way I can think of, is to mount some invisible points on the pole and solve it with some script. However, I like to improve it a little like say, the triangle can be placed at any part of the pole and the pole will fall off either left or right depending on which side is longer (more of a precision rather than the few invisible point that I created). I can't seem to find any function for it, is there such a function?

#1
06/14/2007 (8:21 am)
Erm... can anyone see this post?
#2
06/14/2007 (1:14 pm)
If the pole is all one scene object this could be complicated, in order for the pole to fall to one side, you would have to rotate it, but you would need to set the center/rotation-point to be wherever the fulcrum (triangle/circle) is.

If the pole was just a line drawn between two points, then you can just calculate where the points (ends of the pole) are each tick and redraw it in any position.

I think you have the right idea to 'fake' this in script because the physics engine definitely is not equiped to handle it. One idea would be to see if the midpoint of the pole is above the fulcrim or maybe the midpoint of the fulcrum. Then the speed of rotation or (falling off) would be caculated based on that.
#3
06/14/2007 (1:32 pm)
Isn't the physics engine capable of doing that or do you need some special behavior?



Did some testing with physics and it works quite nicely. The pole slides off from triangle if not in balance which is not good if you want it be fixed but swinging. Then the script based solution is definitely better.
#4
06/14/2007 (1:48 pm)
Collisions do not impart rotational velocity as far as I know. So if you have a long thin object and one of its corners collides with an immobile object, it will not rotate it will just stop. Trying to simulate an object balancing on other with the physics engine (eg. gravity) is just not going to work.

But you can do something that 'looks' like its falling off with some simple math to determine which way and something like moveto and setangularvelocity.
#5
06/14/2007 (9:21 pm)
Rigid body physics.