# How I could find out if two objects are in the same angle

Hi there,

I want to create a little game, but i don’t know I could how to find out if two objects are in the same angle.

My logic is :

variable angleXObject1
variable angleYObject1
variable angleZObject1

variable angleXObject2
variable angleYObject2
variable angleZObject2

if ( angleXObject1 == angleXObject2
&& angleYObject1 == angleYObject2
&& angleZObject1 == angleZObject2 )

Set rectangle inside of the box color Yellow

I have created a space :

CoSpaces Edu :: TestingAngles

I hope someone could help me,

Thank you all,

Have a lovely day,

Stark

1 Like

Hi @Stark, normally you would use the direction block for that; The problem is the way coBlocks handles directions is using quaternions I believe, however these quaternions allow for multiple values to indicate the same visible rotation, so when doing a check (direction of itemA == direction of itemB), it will return false most of the time even if the items look like they are in the same angle.

Best way to do it then is to keep track of the angle yourself, it does mean that you have to manually set the starting angle for both the reference and rotation object, from there on out whenever you change the angle of said object just make sure to adjust the variable, and making the variable loop around at 360 degrees. I’ve done this by checking if the variable after the change is bigger than or equal to 360, if it is I just remove 360 from the value. This makes 360= 0, 361= 1, 362= 2 and so on.

Hope this helps, and good luck!

2 Likes