playMaker

Author Topic: Comparing the angle of two objects  (Read 1120 times)

RobotGoggles

  • Playmaker Newbie
  • *
  • Posts: 35
Comparing the angle of two objects
« 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?
When life hands you insomnia, make video games.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Comparing the angle of two objects
« Reply #1 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.



Bye,

 Jean

RobotGoggles

  • Playmaker Newbie
  • *
  • Posts: 35
Re: Comparing the angle of two objects
« Reply #2 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.
When life hands you insomnia, make video games.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Comparing the angle of two objects
« Reply #3 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