Rotational/Circular Movement
by Kuju Manila · in Torque Game Engine · 05/20/2007 (10:11 pm) · 7 replies
We need objects to constantly move in a circle. So far, we've been doing this by calculating the positions in a schedule (using a constantly decreasing/increasing angle and the math trig functions), then doing a simple setTransform with the calculated values.
Obviously, if the angles are large and the schedules are far in between, you can obviously see the position jumps. On the other hand, lessening the time gap between the schedules ruins the frame rate, which in turn causes large gaps in rendering time instead and still causes jumps in position. And you can't just change one, because then the movement just becomes slow.
Is there an alternate way of doing circular motion perhaps? Or maybe a way to do a frame-based calculation or schedule instead of time-based?
Obviously, if the angles are large and the schedules are far in between, you can obviously see the position jumps. On the other hand, lessening the time gap between the schedules ruins the frame rate, which in turn causes large gaps in rendering time instead and still causes jumps in position. And you can't just change one, because then the movement just becomes slow.
Is there an alternate way of doing circular motion perhaps? Or maybe a way to do a frame-based calculation or schedule instead of time-based?
#2
05/21/2007 (4:20 pm)
@matahari - you might want to consider modifying the engine code if you're not achieving suitable frame rates with smooth animations - the schedule command is only ever an approximation so making things really smooth is very tricky if possible at all, in the engine you can use actual miliseconds to determine your rotations.
#3
I'll look into the engine code, thanks.
05/21/2007 (8:51 pm)
I can't make them items. Sometimes they have to be static shapes, sometimes they have to be players.I'll look into the engine code, thanks.
#4
www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=9480
05/22/2007 (4:49 am)
@Matahari - after writing that I've just found this resource which might be of use to you:www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=9480
#5
What I need to do is actually -move- the objects in an arc, or even in a full circle (or several full revolutions). So I actually need to change their positions constantly, not just their rotational angle. I've been doing this by performing trig functions on an angle that I increment periodically.
I usually do something similar to that in that in a schedule, setting up the transform with the new angles and X,Y values, and doing setTransform. Is there an alternate method?
05/22/2007 (8:25 pm)
I tried the resource and filed it away for safekeeping. It's useful for smooth rotation, but unfortunately it's not exactly what I need.What I need to do is actually -move- the objects in an arc, or even in a full circle (or several full revolutions). So I actually need to change their positions constantly, not just their rotational angle. I've been doing this by performing trig functions on an angle that I increment periodically.
%angle += %increment; // some value in radians
%newX = mCos(%angle) * %radius;
%newY = mSin(%angle) * %radius;I usually do something similar to that in that in a schedule, setting up the transform with the new angles and X,Y values, and doing setTransform. Is there an alternate method?
#6
05/22/2007 (8:37 pm)
Perhaps you can use some of the AIplayer path following routines.
#7
05/23/2007 (5:55 am)
Matahari, it seems like you coud make the angular increment size a function of the radius, speed and perhaps the camera distance and so avoid reducing the frame rate so much.
Torque Owner Caleb
Default Studio Name