playMaker

Author Topic: Get Signed Angle to Target... Isn't getting angle.  (Read 2831 times)

Red

  • Hero Member
  • *****
  • Posts: 563
Get Signed Angle to Target... Isn't getting angle.
« on: April 06, 2015, 04:02:21 PM »
Hey, not sure what's happening here... Whether it's how I have it set up or whether the action itself isn't functioning as expected.

Details: Unity5, Playmaker v1.7.8.3, action from the ecosystem.

Basically, I've tried setting it up on a basic object to only get the rotation. I've even gone into the code to insert some debug.log lines to print out the values it's supposed to work with and no matter what I do, it never gives anything but zeros (either in single floats or vectors.)

I have this on an object... And I want it to get the angle of an object that's a child to this object itself... But no matter what I try it's not doing it.

Further testing to narrow down what's going on... I tried this on another object that rotates all the way around slowly... And the odd thing is, when it's past 90 degrees clockwise and before 180, it produces "180." Not sure what this means but it's an odd result that might be either worth looking at or a red herring.
« Last Edit: April 06, 2015, 04:12:22 PM by Red »

Red

  • Hero Member
  • *****
  • Posts: 563
Re: Get Signed Angle to Target... Isn't getting angle.
« Reply #1 on: April 07, 2015, 10:54:11 AM »
Okay, so after doing some more research I figured out that what I was looking for might not have been what that action was intended to perform... Not sure if it's buggy or not so I put together an action to do what I wanted it to do.

It was actually simpler than I had thought it'd be... No having to go into refreshing the higher maths needed, I just had to figure out the delta angle (a couple links on surveying and city planning helped me understand what this was.)

And I found out there's a function within Unity's MathF systems to do just that. A little tweaking of the systems that used this and I got this working.

I'll include the action (Get Delta Angle) which is bare-bones and very basic... I'm sure it could use some more refining and tweaking to give it more power but as a bare-bones action to do one thing it does what I want it to.

Apologies for doubting since this was a PEBCAK error on my part.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Get Signed Angle to Target... Isn't getting angle.
« Reply #2 on: April 07, 2015, 01:47:23 PM »
Hi,

 Doubled checked the action, it works. I think it's simply because it doesn't make sense for what you want to achieve. but the signed angle is right.

 basically, when you do test, use the "y" for direction, it makes a lot more sense visually, since y is up. so as you move the target around the owner, and keep them both on the same XZ plane, you'll see the signed angle in action.

So if you are on a top down shooter, you can know the angle between the player and an enemy using "y" as a direction, provided the player as the y axis aligned with the top down depth ( world y most likely)


Bye,

 Jean