Top down ball Physics
by Matt Huston · in Torque Game Builder · 07/08/2006 (12:45 pm) · 3 replies
I am thinking of creating a demo for a pool game that has elevation changes. I am looking for some direction on how I would accomplish this. So basically the ball would roll on a normal surface, hit a slope up or down, gain or lose speed based on this. Any ideas from anyone?
About the author
www.atomicbanzai.com
Torque Owner Thomas Buscaglia
For example, create a t2dTrigger, place it where you want the ball to roll downward and set its collision polygon to the edge of the slope. Lets pretend its a northwestern slope - you would create a dynamic field on that trigger called "slope" with a vector in the direction gravity would pull the ball, like "-10 -10". Set your trigger's class field to "SlopeTrigger". Then you would write an onEnter callback for the SlopeTrigger class:
function SlopeTrigger::onEnter(%this, %object) { %object.setConstantForce(%this.slope, true); }You should also consider seting the collision masks on your ball and your triggers and putting a check in your onEnter callback to make sure %object is a ball. Also, this is just one way to do it. I'm sure there are others.