About Store Forum Documentation Contact



Post Reply 
Possible bug with EE::Angle()
Author Message
Lancer Offline
Member

Post: #1
Possible bug with EE::Angle()
Hi,

I'm not sure if this is a bug but this is weird and I can't explain why it happens.

So I have following code:
Code:
EE::Vec2 vLookDir = newPos.xz() - m_pActor->pos().xz();

Now to get the Angle of vLookDir I used the function:
Code:
EE::Angle(vLookDir)
but the result did not work.

Then I tried
Code:
EE::Angle(vLookDir.y, vLookDir.x)

And it works fine.

Results:
   
11-03-2020 03:48 PM
Find all posts by this user Quote this message in a reply
Dwight Offline
Member

Post: #2
RE: Possible bug with EE::Angle()
Hi,

At first glance, you're getting the angle between two xz coordinates. At the end, you're getting an angle between X and Y.

Was that intended or a typo?
11-03-2020 05:03 PM
Find all posts by this user Quote this message in a reply
Lancer Offline
Member

Post: #3
RE: Possible bug with EE::Angle()
(11-03-2020 05:03 PM)Dwight Wrote:  Hi,

At first glance, you're getting the angle between two xz coordinates. At the end, you're getting an angle between X and Y.

Was that intended or a typo?

That's intended
11-03-2020 05:46 PM
Find all posts by this user Quote this message in a reply
Tottel Offline
Member

Post: #4
RE: Possible bug with EE::Angle()
If you're going to pass 2 params instead of 1, according to the documentation, you should first pass x and then y. The fact that you first pass y and then x, makes me think you construct your lookdir vector incorrectly.

Since it's a look direction, make sure you do

Code:
lookdir = posToLookAt - myPos
and not the other way around.
(This post was last modified: 11-04-2020 09:13 AM by Tottel.)
11-04-2020 09:13 AM
Find all posts by this user Quote this message in a reply
Lancer Offline
Member

Post: #5
RE: Possible bug with EE::Angle()
(11-04-2020 09:13 AM)Tottel Wrote:  If you're going to pass 2 params instead of 1, according to the documentation, you should first pass x and then y. The fact that you first pass y and then x, makes me think you construct your lookdir vector incorrectly.

Since it's a look direction, make sure you do

Code:
lookdir = posToLookAt - myPos
and not the other way around.

I already do that.
My code is working fine in my game (client and server-side)

Here you can see:
Look1 - correct
Look2 & Look3 is wrong

   
11-04-2020 03:00 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #6
RE: Possible bug with EE::Angle()
There's no bug.
You're just expecting different results.
11-04-2020 05:01 PM
Find all posts by this user Quote this message in a reply
Post Reply