Moving an item to a defined position.
by Markus Nuebel · in Torque Game Engine · 06/15/2004 (3:46 am) · 5 replies
Hi all.
I need some hints and tips, on how to move and item (Shapebase object) to a predefined position.
Think of all the puzzle games, where you have to push or pull an item, to block something, or to be able to reach a higher ledge (in an FPS) or something like that.
You have an object at location A and a defined destination location B.
When the object is triggered I want to move it from A to B. Obviously I don't want to simply put it to location B with object.setPosition(B), since this would move the object within one frame.
When I am applying an impulse to the item, or setting it's velocity I cannot exactly tell, where it will come to rest (at least not without a hugh amount of experimenting).
Is there a nice solution to move objects from A to B over the course of some frames and have them placed exactly at position B when they come to rest?
Thanks.
-- Markus
I need some hints and tips, on how to move and item (Shapebase object) to a predefined position.
Think of all the puzzle games, where you have to push or pull an item, to block something, or to be able to reach a higher ledge (in an FPS) or something like that.
You have an object at location A and a defined destination location B.
When the object is triggered I want to move it from A to B. Obviously I don't want to simply put it to location B with object.setPosition(B), since this would move the object within one frame.
When I am applying an impulse to the item, or setting it's velocity I cannot exactly tell, where it will come to rest (at least not without a hugh amount of experimenting).
Is there a nice solution to move objects from A to B over the course of some frames and have them placed exactly at position B when they come to rest?
Thanks.
-- Markus
About the author
#2
I'm not sure if there's a class already available for this kind of thing either (I know there is in TSE, just cant remember if its from TGE or not).
Also, if your interested in making something similar, you could look for frank bignone's pathed object resource on here. Does a similar thing using his own path objects, so a cross between using GG's pathcamera and franks pathobject should do what you need.
06/16/2004 (3:24 am)
Yeah, what you need markus, is a pathable object. Now there is a pathcamera class in the current HEAD which is shapebase derived, so in theory you could use that.I'm not sure if there's a class already available for this kind of thing either (I know there is in TSE, just cant remember if its from TGE or not).
Also, if your interested in making something similar, you could look for frank bignone's pathed object resource on here. Does a similar thing using his own path objects, so a cross between using GG's pathcamera and franks pathobject should do what you need.
#3
Thats what a lot of games do, it produces a nice sine type motion that slows down as it reaches the final position.
06/16/2004 (3:26 am)
Another suggestion, is to use setposition, but to calculate the distance to the new position from the current, divide that by two every frame and set that as the new position, then when its near enough that dividing isnt useful, simply set it at the position.Thats what a lot of games do, it produces a nice sine type motion that slows down as it reaches the final position.
Torque Owner Markus Nuebel
Even ideas, hints or pointers would help.
-- Markus