Forum

> > CS2D > Scripts > Get X and Y based on rotation
Forums overviewCS2D overview Scripts overviewLog in to reply

English Get X and Y based on rotation

6 replies
To the start Previous 1 Next To the start

old Get X and Y based on rotation

Mami Tomoe
User Off Offline

Quote
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.

old Re: Get X and Y based on rotation

Bowlinghead
User Off Offline

Quote
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"?
More >

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.
edited 1×, last 08.12.19 09:16:26 am

old Re: Get X and Y based on rotation

SQ
Moderator Off Offline

Quote
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
edited 2×, last 08.12.19 11:28:32 am
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview