Forum

> > CS2D > Scripts > Get X and Y based on rotation
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Get X and Y based on rotation

6 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt Get X and Y based on rotation

Mami Tomoe
User Off Offline

Zitieren
I have (pixel) X and Y.
I also have a rotation.

I want the X and Y to point at the object.

IMG:https://i.imgur.com/AR24s1N.png


This might explain it better, it's hard for me to explain.

alt Re: Get X and Y based on rotation

Bowlinghead
User Off Offline

Zitieren
Okay. How can a circle can have a rotation?
And if your result is really this rectangle I dont get how you came to the solution.

So you have a starting point with X,Y and rot? Then you want to see the next objects this point is "watching at"?
Mehr >

I would increment the view distance and check everytime if something is on the way.
Once you hit it you do know c and all angles in my triangle. Then you can get whatever you want.
1× editiert, zuletzt 08.12.19 09:16:26

alt Re: Get X and Y based on rotation

SQ
Moderator Off Offline

Zitieren
Probably he means that:

He has Object A and Object B
He wants to set rotation of Object A so it is looking at Object B

1
rotation = Atan2(objectA.y - objectB.y, objectA.x - objectB.b)

After you get rotation, you can push your old position towards the new one.
1
2
ObjectA.x + cos(rotation) * distance
ObjectA.y + sin(rotation) * distance
2× editiert, zuletzt 08.12.19 11:28:32
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht