Ça donnerais :
Code:
local Vector HitLocation, HitNormal, End, Start;
local Actor HitActor;
local float LenC, LenA, LenB;
local float alpha, playerSide;
local vector dotNormal, VecMP, VecMN, temp;
Start = Pawn.Location + (Vector(Pawn.Rotation));
End = Start + (vector(Pawn.Rotation) * 2048);
HitActor = Trace(HitLocation, HitNormal, End, Start, true,);
`Log("HitActor = " @ HitActor);
`Log("Start = " @ Start);
`Log("End = " @ End);
`Log("Rotation = " @ Vector(Pawn.Rotation));
`Log("HitNormal.X = " @ HitNormal.X);
`Log("HitNormal.Y = " @ HitNormal.Y);
`Log("HitNormal.Z = " @ HitNormal.Z);
dotNormal = HitLocation + HitNormal;
LenC = VSize(Pawn.Location - HitLocation);
LenA = VSize(Pawn.Location - dotNormal);
LenB = VSize(HitLocation - dotNormal);
VecMP = HitLocation - Pawn.Location;
VecMN = HitLocation - dotNormal;
`Log("C (Player to location) = " @ LenC);
`Log("A (Player to normal) = " @ LenA);
`Log("D (Wall to normal) = " @ LenB);
temp = VecMN cross vect(0,0,1);
alpha = Normal(VecMP) dot temp;
playerSide = Sin(Alpha);
`Log("Alpha = " @ Alpha);
`Log("PlayerSide = " @ PlayerSide);
if(playerSide <= -0.5 )
{
`Log("--Player it à Left !");
}
else if(playerSide >= 0.5)
{
`Log("--Player it à Right !");
}
else
{
`Log("--Player it à Face !");
}
Je suis presque satisfait, sauf que pas tout à fait. Parfois même si le joueur est sur le côté mon angle me retourne "face"... Ou alors droite alors que je suis du côté gauche... Il suffit que je bouge un peu le joueur pour que ça se corrige...
---------- Post ajouté à 14h37 ----------
Envoyé par
Møgluglu
Hmmm, je vais regarder ça...