We are going to make a object orbit another object and orbit it around where ever he goes. To start, we put this in the create event:
code:
orbit_angle = 500;
orbit_radius = 50;
orbit_speed = 10;
I will explain this more in a minute, orbit_angle is going to be the angle of the orbiting object. Orbit_radius is going to be the radius (how big) of the orbit. And orbit_speed is going to be how fast it will go when in orbit.
Here is the next code and it goes in the step event:
code:
orbit_angle += orbit_speed;
x = obj_player.x + orbit_radius * cos(orbit_angle * pi / 360);
y = obj_player.y - orbit_radius * sin(orbit_angle * pi / 360);
This is all you need to do to make the object angle. You can always change the values of orbit_angle and orbit_radius to get a different orbit. If you look at the code in the step event you can see its pretty easy to understand.
Make sure that you change obj_player to what ever name it is for the object that you want to be orbited.
Heh I remember this.
ReplyDelete-Rapidfireshot
yeah, its what we used in our game. But I am the one who came up with it.
ReplyDeleteThis comment has been removed by the author.
ReplyDelete