# Setting RotationY depending on two coodinates

This topic is 5057 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hello, I am not very good with Maths, maybe somebody can help me out. I have a planet with coordinates PX,PY,PZ. I have a Stargate flying around the planet with coordinates SX,SY,SZ. PY is equal SY, Y is up (0/1/0). this is working fine. Now I wnat my stargate to always point to the planet whereever it is. So I need to set MatrixRotationY with (Stargate.matrot,???) How do I get the value for the rotation depending on my coordinates? Thanks a lot! Firle

##### Share on other sites
You could make the planet and Stargate as one object. But that's maybe not what you want.

You can use one matrix if you make the Stargate's pivot in the center of the planet. But maybe that's not what you want either...

But at least I think that's the only solution... else you might have to change the Stargate's position and then rotate it afterwards.

##### Share on other sites
Hi!

Thanks for the answer, I am changing the stargates position every frame, it is rotating around the planet.

But it must be possible to rotate it depending on those two coordinates to point to the planet! I have the same problem with my starship, should be flying to a certain point. The question is what value to insert into MatrixRotationY.

I think it must be a formula with SX,SZ and PX,PZ.

Firle

1. 1
2. 2
Rutin
21
3. 3
A4L
15
4. 4
5. 5

• 13
• 26
• 10
• 11
• 44
• ### Forum Statistics

• Total Topics
633740
• Total Posts
3013621
×