playMaker

Author Topic: Problem to get Angle between two points[SOLVED]  (Read 3169 times)

Oni Lo

  • Playmaker Newbie
  • *
  • Posts: 4
Problem to get Angle between two points[SOLVED]
« on: October 28, 2013, 12:09:55 PM »
Please excuse me for my bad English.

I am creating a virtual joystick to move a character (camera angle like Diablo III ) . Everything is working perfectly , except that I can not rotate the character according to the direction of the joystick yet.

I created two GuiTexture . One appears where the player touches and remain in the same position until the touch ends. The second appears and follows the touch every frame .
( e.g. the gray base is the first image and the red ball is the second image.)

I'm trying to get the angle between these two GUITextures , turning them into Vector2 and using Vector2Operator/Angle, but I'm having very strange results (float ), it seems that it returns me something like the distance between these two GUITextures, not the angle or something similar.
I've also tried converting the position of each GUITexture for World Position and then use Vector3Operator/Angle but no success.

Someone could tell me what I'm doing wrong or have any other solution?

Thank you!
« Last Edit: October 30, 2013, 08:31:22 AM by jeanfabre »

Oni Lo

  • Playmaker Newbie
  • *
  • Posts: 4
Re: Problem to get Angle between two points
« Reply #1 on: October 28, 2013, 07:24:32 PM »
I changed Vector3Operator/Angle to Distance and I got the same Float value. Vector3Operator is giving me a distance instead of an angle.

Is this a bug?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Problem to get Angle between two points
« Reply #2 on: October 29, 2013, 03:44:18 AM »
Hi,

 I double checked, and Vector3 operator properly return the angle or distance based on your selection.

Can you double check on an simple test fsm, if you have trouble still, let me know.

bye,

 Jean

Oni Lo

  • Playmaker Newbie
  • *
  • Posts: 4
Re: Problem to get Angle between two points
« Reply #3 on: October 29, 2013, 10:16:35 AM »
I know the script is not wrong. It is very simple to be wrong!  :D

As I don't have much experience, I believe that there is some trick that I do not know.  :P
I made a new project with the problematic part: https://dl.dropboxusercontent.com/u/159948340/joystick.rar (removed)
(The Vector2Operator/Angle is in gui_joystick object)

In my game, I put an object in the position of the joystick base looking at the joystick thumb. Then I used the rotation Y in the character. It works, but i belive that is not the most elegant way.

Thank you very much for your time!
« Last Edit: October 30, 2013, 06:15:11 AM by Oni Lo »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Problem to get Angle between two points
« Reply #4 on: October 30, 2013, 02:20:09 AM »
Hi,

 Dropbox link leads nowhere.

bye,

 Jean

Oni Lo

  • Playmaker Newbie
  • *
  • Posts: 4
Re: Problem to get Angle between two points
« Reply #5 on: October 30, 2013, 05:57:26 AM »
Oh, sorry. I removed it because it is no longer necessary.
Searching in Unity forums, I realized that Vector2Angle or Vector3Angle not provide us an angle in degrees or something that can be used directly in Set Rotation, Smooth Look At, Smooth Look At Direction, Look At or to make an object look at a specific angle. That only gives us a number to work in an attempt to find an angle in degrees or something usable (in my case).
I'm not good in C # but I'll try to create an Action with two Vector2 that returns something useful in my case.

Thank you!
« Last Edit: October 30, 2013, 06:11:45 AM by Oni Lo »