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


#1

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.


#2

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.


#3

I think I can help.

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


#4

Here’s a little demo @Scantron_46 :


#5

Here:

Hopscotcher beat me to it tho.

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


#6

It’s explained better though.


#7

Thanks.

I probably did it wrong tho haha


#8

I checked code and it’s all right.


#9

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


#10

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


#11

Yeah lol I got that.
Thanks tho.


#12

k bye


#13

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
End
Or something like it that code won’t work but I would try other ways of doing that


#14

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


#15

Like how your realistic orbit sim works!


#16

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


#17

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


#18

Ya that is what I would think


#19

Thanks everyone!
(20 characters)


#20

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