Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: RobotGoggles on February 23, 2020, 11:21:04 PM

Title: Comparing the angle of two objects
Post by: RobotGoggles on February 23, 2020, 11:21:04 PM
So I'm trying to compare the angle of two objects and call an event if they're equal within a certain range. Vector3 Compare sort of works, but it doesn't account for objects that are below zero, since the rotation values jump from 359 back to 0 so there are negative numbers.

I could get the raw rotation values to get negative rotation, but then I won't be able to account for objects that have been rotated multiple times.

Surely there must be a simple way to do this?
Title: Re: Comparing the angle of two objects
Post by: jeanfabre on February 24, 2020, 03:46:24 AM
Hi,

 unfortunatly, no, there isn't a simple solution for this, quaternions and euler angles are complex math, but there are some custom actions that wrap the complexity.

check out "GetSignedAngleToTarget" custom action on the ecosystem, that will help you get a signed angle.

(https://i.imgur.com/nukdo9D.png)

Bye,

 Jean
Title: Re: Comparing the angle of two objects
Post by: RobotGoggles on February 25, 2020, 01:31:51 AM
Thanks for the reply, but I don't see how this is going to work for my purposes. I'm just trying to compare the rotation values, not dependent on position.
Title: Re: Comparing the angle of two objects
Post by: jeanfabre on February 25, 2020, 02:00:09 AM
Hi,

 you can't have a signed angle if you don't have a reference to define where is the positive and where is the negative.

in your case, you can manually check if the value is greater then 180, which then means it's a negative angle.

Bye,

 Jean