Calculate Angle to look at person
#1

How can i calculate the "SetPlayerFacingAngle",
so that the person i want to interact with is facing another player ?

Found "GetXYInFront" or sth similiar,
but i dont think, that its made for this.

So, i hope someone can help me with this.

Last time i made a loop from 0 to 360 degrees and checked, if the person is close to this,
but this is very ressource wasting...
Reply
#2

GetPlayerFacingAngle?
Reply
#3

Read my question?
Reply
#4

Find some function which calculates the angle between 2 points, then get the angle between player A and player B and check if the angle is equal to player A's facing angle. If it is so - do what u want.

Edit: Oh, you wanted to SET the facing angle? So calculate the angle and set the other player's facing angle to that. lol

You might need to make it OPPOSITE angle, so just do angle -= 180.0.
Reply
#5

That doesnt make sense.
It doesnt matters, where Player A is looking, to get Player B looking to him.

I just want to retrieve the angle,
which i have to set, to make Player A looking at Player B
Reply
#6

180>?

[edit] u want setplayerfacingangle(playerid, anglehere?)
Reply
#7

Quote:
Originally Posted by Trooper[Y]
Посмотреть сообщение
That doesnt make sense.
It doesnt matters, where Player A is looking, to get Player B looking to him.

I just want to retrieve the angle,
which i have to set, to make Player A looking at Player B
What?

Quote:
Originally Posted by Finn
Посмотреть сообщение
Find some function which calculates the angle between 2 points, then get the angle between player A and player B
Quote:
Originally Posted by Finn
Посмотреть сообщение
So calculate the angle and set the other player's facing angle to that.
If this doesn't make sense, it's weird why it works in my script.
Reply
#8

pawn Код:
stock LookAtEachother(playerid, otherplayer)
{
    new
        Float:rotation;
       
    GetPlayerFacingAngle(playerid, rotation);
   
    rotation -= 180.0
    SetPlayerFacingAngle(otherplayer, floatabs(rotation));
}
SECOND EDIT:

I think Floatabs does the trick.

https://sampwiki.blast.hk/wiki/Floatabs

Lol not much info, but you can see the two examples.
Reply
#9

What if player A is not looking at player B?

That code would make it end up like this:

Код:
|
o   o
    |
o = player
| = facing angle
Reply
#10

Wouldn't that be extremely buggy? for example, if you were to set the X/Y and there was a building next to you?

Anyway, it's just an example (lol even I learnt something.. didn't know what Floatabs was)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)