I'm having issues trying to get one or more objects to orbit around another. Is there a tutorial available that I can study off of?
Printable View
I'm having issues trying to get one or more objects to orbit around another. Is there a tutorial available that I can study off of?
I remember an extension made specifically for this. Called Orbit I think, check the extension websites.
One of the Clickteam Movement might allow for this. Didn't check though.
There are a few methods to do this. Either you can use the "vector movement" together with "clickteam movement controller", and pull the orbiting object toward the other. It's of course also possible to do this without extensions, using some expressions.
For another type of orbiting, you can also use this technique:
[Always]
Set X Position of "Orbiter" to X( "Center of rotation" )+(Sin(Rotation( "Orbiter" ))*Distance( "Orbiter" ))
Set Y Position of "Orbiter" to Y( "Center of rotation" )+(Cos(Rotation( "Orbiter" ))*Distance( "Orbiter" ))
Rotation and Distance are alterable values. Now you just have to increase the "rotation" value to have it orbit the center object. Don't forget to set the "distance" value to something higher than 0.
I'd prefer to not use extensions. But the formula you've given me only makes the orbiting object hang in midair instead of orbiting around the player character like I want it to. (Screens below).
NOTE: The bright blue dot on Mega Man's chest is the center of rotaton object.
http://www.fangamez.net/orbiterproblem.png
Here's a screen from my event editor, using that formula.
http://www.fangamez.net/orbiterproblem2.png
I think you're missing this one.Quote:
Originally Posted by Nifflas
You want something along the lines of:
* Always
- (Active 2) : Set X position to X( "Active" )+100*Sin(Alterable Value A( "Active" ))
- (Active 2) : Set Y position to Y( "Active" )+100*Cos(Alterable Value A( "Active" ))
- (Active) : Add 1 to Alterable Value A
Wrong.Quote:
Originally Posted by OliverPearl
Rotation = 4
Distance = 16
I set those before even putting in the formula.
Thanks Josh. I'll try that out.
EDIT: It works with a single object, is it possible to have more than one object orbiting around the central object at the same speed as the first (But different positions)?
An example would be:
http://www.fangamez.net/example.gif
Yes. Use spread value on the orbiting objects, then instead of using just the Alt A of the center object, use Alt A of Center Object + (Alt A of Orbiting Object * 50 ) or similar.Quote:
Originally Posted by Strider
Actually, you was misunderstanding that one. I meant that you have to increase or decrease the "rotation" value on [Always], not just set a static value once. I also recommend that you limit the rotation values to 0-359 by using these events:Quote:
Originally Posted by Strider
[If rotation > 0]
Add 360 to rotation
[If rotation > 359]
Sub 360 from rotation
Thank ya sir.
Sorry to dredge up an old thread, but is it possible to get the orbiting movement with Nifflas's example to work but starting at different points in the circle?
I don't want all the orbiting objects to start from the same position.
Thanks,
Tom / Doc4
Yes, just set the "rotation" alterable value to a random number when you create the object.
Well OBVIOUSLY that's the easy answer, Dynasoft. You'd have to be an idiot not to know that.
** smugly walks away until out of sight where he writes the answer down with excitement **
I have a ship fly towards a planet and, within a distance of 50, start to orbit. How can I set the ship's rotation start point based on where it is in reference to to planet?
I tried using Get Direction from the ADO, but it doesn't work as intended.
I want the ship to get within 50 and start orbit from that same spot.
Thanks,
Tom / Doc4
You need to get the angle from the planet to the craft. I think.
Does MMF have atan2 yet?
I've done ship to planet and planet to ship. It keeps putting the ship at unexpected locations.
Unfortunately my math skills do not extend beyond A+1=2. I had to copy and paste the Sin/Cos code from this thread to get things working to begin with.
Any suggestions?
Here are some screen shots if they are of any use.
http://img412.imageshack.us/my.php?image=radiushelpmh5.png
The formula isn't quite right, it should be the following to match MMF's angles:
[Always]
Set X Position of "Orbiter" to X( "Center of rotation" )+Cos(Rotation( "Orbiter" ))*Distance( "Orbiter" )
Set Y Position of "Orbiter" to Y( "Center of rotation" )-Sin(Rotation( "Orbiter" ))*Distance( "Orbiter" )
And initial rotation should be: (advanced direction object) longdir(planet x, planet y, ship x, ship y) with number of directions set to 360.
Works perfectly. Angles all line up.
The ship's captain would like to thank you for fixing the abrupt time/space leaping when he tried to orbit. He no longer needs a ship's chiropractor on staff.
Tom / Doc4