playMaker

Author Topic: Getting Angle out of a Vector3 operator, Store Float result wrong?  (Read 3194 times)

markinjapan

  • Full Member
  • ***
  • Posts: 103
Getting Angle out of a Vector3 operator, Store Float result wrong?
« on: September 25, 2011, 11:26:05 AM »
Hi,

Am I right in thinking that if I feed in 2 Vector3 and set the operation to 'Angle' I will get the angle between the 2 vectors?

Because when I look at the 'Store Vector result' it is always 0,0,0.

I've also tried storing the Float (as that seems to give me something viable) but when I apply value to an object (via Set Position - Zangle) I get some strange results, the object rotates but it's ever so slightly off (83.7 instead of 90).

Thanks for any help.




jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Getting Angle out of a Vector3 operator, Store Float result wrong?
« Reply #1 on: September 26, 2011, 03:22:52 AM »
Hi,

 the Angle operation between two vectors return an absolute angle as a float, not the angle as in a vector3. So yes, you need to watch the float result variable and leave the Vector result variable.

 I tested it and it works accuratly for me. Tho I realize one mistake in the script: it requires the vector3 result variable which in this case is erronous, will notify alex so that he can include the fix for 1.2.1. you can redownload the script here: http://hutonggames.com/playmakerforum/index.php?topic=271.0

 If you are willing to share the scene where you have this problem, I can look at it ( pm me if this is private)


 Bye,

 Jean

markinjapan

  • Full Member
  • ***
  • Posts: 103
Re: Getting Angle out of a Vector3 operator, Store Float result wrong?
« Reply #2 on: October 02, 2011, 08:19:59 PM »
Hi,

Thanks for the help.

Well, it looks like I'm just using it wrong. I was expecting to get the angle between 2 vectors but I expect I'm just doing it wrong.

This is my set up.

I have 2 gameobjects which are next to each other in the x axis. Since they are parallel (I just duplicated and moved one across) I was expecting that the angle I would get (by getting the vectors for the gameobject and using the vector3 operator/ angle / float value) would be 90 or 270 (if 0 is up).

But this is not the case, as the angle is something like 47.

What I want to do is get the angle between 2 gameobjects and have one of the gameobjects angled to 'look at' the other gameobject as it moves around it. Imagine the moving object was a circle and the other gameobject was an arrow, I want that arrow to always point at the circle.

I expect I should be using the 'Look at' Action but I wanted to work out how the 'angle' operator worked in the vector3 operator as this seems like a useful thing to know.

Thanks