Calculate Angle to look at person -
Trooper[Y] - 16.07.2010
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...
Re: Calculate Angle to look at person -
Dudits - 16.07.2010
GetPlayerFacingAngle?
Re: Calculate Angle to look at person -
Trooper[Y] - 16.07.2010
Read my question?
Re: Calculate Angle to look at person -
Finn - 16.07.2010
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.
Re: Calculate Angle to look at person -
Trooper[Y] - 16.07.2010
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
Re: Calculate Angle to look at person -
Kar - 16.07.2010
180>?
[edit] u want setplayerfacingangle(playerid, anglehere?)
Re: Calculate Angle to look at person -
Finn - 16.07.2010
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.
Re: Calculate Angle to look at person -
Joe_ - 16.07.2010
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.
Re: Calculate Angle to look at person -
Finn - 16.07.2010
What if player A is not looking at player B?
That code would make it end up like this:
o = player
| = facing angle
Re: Calculate Angle to look at person -
Joe_ - 16.07.2010
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)