controllable orbit question
by Levi Walton · in Torque Game Builder · 02/04/2010 (6:32 pm) · 25 replies
I would like to make an object orbit around another, being able to adjust the direction of the orbit and even the radius at times. I've searched and havent really found anything terribly useful. I thought it would involve polar coordinates being converted to cartesian, but in some of my searching it said that tgb doesnt use cart coordinates, i had some sucess with that, but the problems i had might be due to this. i have also noticed several torque scripts with references to "polar", such as setPolarVelocity etc. are these the commands i should be looking at? any and all info would be appreciated. thanks
#22
02/11/2010 (6:01 pm)
well believe me, i find it weird that %this.radius works too, since i tried it on my own lol. %this.current angle seems to put it at 0.0 regardless of what value i set it too. i can set it to 90.0, 180.0, 45.0 etc and it still puts it in the same place when the project its run. its all very confusing to me.
#23
TorqueScript is VERY unforgiving of mis-spellings. You might check in your onUpdate that you are using "%this.currentAngle", spelled the exact same way. If you had, say "%this.angleCurrent" (a mistake I commonly make), it would still work because Torque would "initialize" it to 0.
02/11/2010 (7:04 pm)
One more thought:TorqueScript is VERY unforgiving of mis-spellings. You might check in your onUpdate that you are using "%this.currentAngle", spelled the exact same way. If you had, say "%this.angleCurrent" (a mistake I commonly make), it would still work because Torque would "initialize" it to 0.
#24
thanks for the help
02/12/2010 (2:00 pm)
it looks like its all the same, i actually copied and pasted one under the other to compare. but im sure its something along those lines, i figured it would be set to 0 by default and thats why. i guess ill just go over all of it and try and find something. and if i get that straight my next task will be to see if i can make it jump on its orbit and return back to its original radius. i think i have an ide of how to do this, but im sure ill have tons more questions:Pthanks for the help
#25
Essentially, it spawns a number of t2dAnimatedSprites (the example uses the default particle art) and sets them rotating at a radius depending on the object's size that was selected. The code isn't perfect, I'm having trouble scaling the speed according to the size of the object as you'll see when you click the wider box. I could use some suggestions here...
If there is interest, I'll convert it to a resource or perhaps simply a behavior. Please let me know if you are interested.
02/19/2010 (12:05 pm)
I created a prototype that uses this orbit code for indicating selected objects. You can get it here.Essentially, it spawns a number of t2dAnimatedSprites (the example uses the default particle art) and sets them rotating at a radius depending on the object's size that was selected. The code isn't perfect, I'm having trouble scaling the speed according to the size of the object as you'll see when you click the wider box. I could use some suggestions here...
If there is interest, I'll convert it to a resource or perhaps simply a behavior. Please let me know if you are interested.
Associate William Lee Sims
Machine Code Games
I find it weird that your "%this.radius = ..." works, but that the angle-to-point doesn't.