Question about T2DForceComponent
by Harrison Brock · in Torque X 2D · 05/15/2007 (1:52 pm) · 5 replies
I have added a T2DForceComponent to a object. But I want a force to be apply when I press a key so that the object will move a few units (N,S,W,E). Will I have to change the MovementComponent.cs to apply the force when the Key is press.
#2
05/24/2007 (9:08 am)
You should generally avoid using the global input map for gameplay-related things. The movementComponent is an example of how to properly map movement input. The global input map should be used for things like menu toggling, screenshot hotkey, etc that need to always be active and aren't neccesarily tied to an active object or GUI Control.
#3
unfortunatly MovementComponent doesnt give any example of the difference using .Global or not, but i think it's safe to assume that you can change inputmaps dynamically using the non .Global accessor.
05/31/2007 (10:03 pm)
So to be clear, Thomas is suggesting to use what I said, except remove the .Global part of the example. unfortunatly MovementComponent doesnt give any example of the difference using .Global or not, but i think it's safe to assume that you can change inputmaps dynamically using the non .Global accessor.
#4
I have objects i want to steer via AI functions, the objects move along a vector equal to their rotation (so they always head straight forward), the AI functions generate a Steering Force that would rotate the object (thus steering it towards or away from a target at a maximum allowed rate) and a Breaking Force that would slow it down if necessary
Edit: Actually i can see they can be used to rotate objects but im none the wiser as to how.
07/17/2007 (8:08 am)
So are force components just used to move objects or can they also be used to rotate them? Example:I have objects i want to steer via AI functions, the objects move along a vector equal to their rotation (so they always head straight forward), the AI functions generate a Steering Force that would rotate the object (thus steering it towards or away from a target at a maximum allowed rate) and a Breaking Force that would slow it down if necessary
Edit: Actually i can see they can be used to rotate objects but im none the wiser as to how.
#5
07/17/2007 (8:43 am)
Apply the force to some point off of the center of the object and you'll get rotation due to the torque.
Torque Owner Jason Swearingen
if you want to use forces with key input, just bind a key, and set the force in that direction, based on that value.
to bind a delegate to a key input, use :
GarageGames.Torque.Sim.InputMap.Global.BindAction(_id,(int) key, toExecute);
then just set your t2dStaticSprite.Force inside of the delegate. for better examples, look in the various sample projects
hope that helps