VectorSatyr Posted July 10, 2006 Report Share Posted July 10, 2006 Let's say we have object A and object B. How would I pull object B into an orbital position around object A? I'd try it myself, but I don't know any algorithms for finding the positions on the edge of a circle. :/ For clarity: "Orbital" meaning "circulating around an object." Object B, from a distance, would fly towards a position around object A that is empty; we assume that the position is rotating around object A, so object B would adjust its trajectory towards the rotating point. Link to comment Share on other sites More sharing options...
Smidge204 Posted July 10, 2006 Report Share Posted July 10, 2006 This is an excellent example of where precalculating values can help simplify and speed things up First, you will need to specify two values: Radius (Distance to maintain between objects) and Angle. Object A is the central object. It is located at (Ax,Ay). Object B is the orbiting object. It is located at (Bx,By). Bx = Ax + (Cos(Angle)*Radius) By = Ay + (Sin(Angle)*Radius) If that doesn't work quite right, try swapping the + for a - in either equasion. I'm assuming a few things about how the coordinate system and sin() and cos() functions work. Move object A first, before doing any math, to keep object B in it's proper place. (positioning object B before moving A will create a slight lag effect, which you might actually want...) You can also make nifty spiraling effects by changing Radius. =Smidge= Link to comment Share on other sites More sharing options...
Asuma Posted July 10, 2006 Report Share Posted July 10, 2006 Like this? http://rapidshare.de/files/25492727/ObjRotation.rar.html Nitemare made this a while back. Link to comment Share on other sites More sharing options...
LarkSS Posted July 11, 2006 Report Share Posted July 11, 2006 This is an excellent example of where precalculating values can help simplify and speed things up First, you will need to specify two values: Radius (Distance to maintain between objects) and Angle. Object A is the central object. It is located at (Ax,Ay). Object B is the orbiting object. It is located at (Bx,By). Bx = Ax + (Cos(Angle)*Radius) By = Ay + (Sin(Angle)*Radius) If that doesn't work quite right, try swapping the + for a - in either equasion. I'm assuming a few things about how the coordinate system and sin() and cos() functions work. Move object A first, before doing any math, to keep object B in it's proper place. (positioning object B before moving A will create a slight lag effect, which you might actually want...) You can also make nifty spiraling effects by changing Radius. =Smidge= I definately gotta remember that. I was wondering myself on how to do it without using the Orbit extension. Link to comment Share on other sites More sharing options...
sonic101 Posted July 11, 2006 Report Share Posted July 11, 2006 is this in game maker? if so orbits are easy heres an example from my game lets say object A is the blueladybug_right and object B is the orbit in the step even of the object b type with(blueladybug_right) if distance_to_object(orbit)<200 { bob=instance_nearest(x,y,orbit); dir-=2 x=bob.x+lengthdir_x(40,dir) y=bob.y+lengthdir_y(40,dir) } this checks if object A is near the orbit (object object, then it selects the nearest one so you dont end up with glitches if more of them are on screen. dir will just make it rotate left or right depending on if a "-" or a "+" is used. then with the lengthdir commands it finds the angles or what ever, and the number 40 there is how many pixels away from the orbit object you want the orbiting object A to be. lol i finally got to help you AeroGP.( instead of the otherway around) I think this is what your looking for. but do correct me if im wrong. Link to comment Share on other sites More sharing options...
LarkSS Posted July 11, 2006 Report Share Posted July 11, 2006 I'm using MMF, but I believe I can easily put that into it. You seem to have used two set numbers instead of all variables. Is that the way it should be or is it just an example? Link to comment Share on other sites More sharing options...
VectorSatyr Posted July 11, 2006 Author Report Share Posted July 11, 2006 Nah, it's just one way to do it. And I appreciate the help both of you have given me. Now I can really show what my engine can do. Link to comment Share on other sites More sharing options...
Recommended Posts