How can I make an object orbit around a moving object?


I’m making a game, and I want an object to repeatedly circle another object, but I don’t know how to make it follow it around as it moves.


Welcome to the forum!
I don’t know how to do that, but I’m pretty sure it’ll involve sine and cosine.
@CodeHelp might be able to help.


I think I can help.

Give me a while and I’ll whip something up for you and post the link here


Here’s a little demo @Scantron_46 :



Hopscotcher beat me to it tho.

Just ignore the fact that it’s from Fearless’ alt


It’s explained better though.



I probably did it wrong tho haha


I checked code and it’s all right.


Yeah, no, I know the code is fine, I was talking about what they were asking for. I wasn’t sure if I did the thing they requested


I read the first post again and it’s right.


Yeah lol I got that.
Thanks tho.


k bye


You could probably use something like
When game starts
| Set pos. X1+how far x and Y1+how far y
| Increase how far by 1
Or something like it that code won’t work but I would try other ways of doing that


Probably involves sine, cosine, and the unit circle, like @tankt2016 said.


Like how your realistic orbit sim works!


Yes somewhat I still can’t get it to work correctly lol


You can make an object go in artificial orbits. I think that’s what @Scantron_46 wants.


Ya that is what I would think


Thanks everyone!
(20 characters)


One more question, whenever I try to post something it says that my post is pending. Why is that?