Portal SAMP
[Ajuda] Objeto a Frente do Player - Versão de Impressão

+- Portal SAMP (https://portalsamp.com)
+-- Fórum: SA-MP (https://portalsamp.com/forumdisplay.php?fid=5)
+--- Fórum: Área de suporte (https://portalsamp.com/forumdisplay.php?fid=6)
+--- Tópico: [Ajuda] Objeto a Frente do Player (/showthread.php?tid=1662)



Objeto a Frente do Player - Levi.M - 26/09/2021

Olá, estou com problemas pra acertar na coordenada do objeto que quero por a frente do jogador. Tentei colocar pela posição Y e a Posição do Anglo (Posição A) mas não funcionou, está ficando atrás do jogador. Quero deixar o objeto na frente do jogador, se alguém puder ajudar, agradeço.


Código PHP:
PlayerInfo[playerid][Objbomba] = CreateObject(1654PlayerInfo[playerid][pxx], PlayerInfo[playerid][pxy],PlayerInfo[playerid][pxz],0.0,0.0,PlayerInfo[playerid][pxa]); 



RE: Objeto a Frente do Player - ipsLuan - 26/09/2021

Isso é questão de lógica.
Basta você ajustar o seu X/Y de acordo com a necessidade: Adicione + 1.0, se ir pra trás, você substitui por subtração.

Se for muito a frente, diminua. Se ficar pouco a frente, aumente.


RE: Objeto a Frente do Player - Levi.M - 26/09/2021

Consegui, obrigado.


RE: Objeto a Frente do Player - willttoonn - 28/09/2021

Use esta função para obter o X e Y da frente do jogador:

Código:
GetXYInFrontOfPlayer(playerid, &Float:x, &Float:y, Float:distance)
{
    new Float:a;
    GetPlayerPos(playerid, x, y, a);
    GetPlayerFacingAngle(playerid, a);
    if (GetPlayerVehicleID(playerid))
    {
        GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
    }
    x += (distance * floatsin(-a, degrees));
    y += (distance * floatcos(-a, degrees));
}