Hey,
wie verwende ich Vektoren, wenn ich im Auto sitze?
Also ich möchte, dass da, wo das Auto hinguckt, eine Rackete hingeschossen wird.
Aber es wird immer dahin geschossen, wo ich mit der Camera hingucke..
Codeschnipsel:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(newkeys & KEY_FIRE)
{
if(!IsPlayerInAnyVehicle(playerid)) return 1;
if(!rpgvar[GetPlayerVehicleID(playerid)]) return 1;
new veh = GetPlayerVehicleID(playerid);
new Float:x1, Float:y1, Float:z1, Float:x2, Float:y2, Float:z2, Float:end_x, Float:end_y, Float:end_z, Float:X, Float:Y, Float:Z, Float:A;
GetVehiclePos(veh, X, Y, Z);
GetVehicleZAngle(veh,A);
new rak = CreateObject(345, X, Y, Z+0.75, 0, 0, A, 300.0);
const Float:fScale = 200.0;
GetPlayerCameraPos(playerid, x1, y1, z1);
GetPlayerCameraFrontVector(playerid, x2, y2, z2);
end_x = x1 + floatmul(x2, fScale);
end_y = y1 + floatmul(y2, fScale);
end_z = z1 + floatmul(z2, fScale);
MoveObject(rak,end_x,end_y,end_z,30.0);
SetTimerEx("Exp", 2200, 0, "d",rak);
}
return 1;
}
{
if(newkeys & KEY_FIRE)
{
if(!IsPlayerInAnyVehicle(playerid)) return 1;
if(!rpgvar[GetPlayerVehicleID(playerid)]) return 1;
new veh = GetPlayerVehicleID(playerid);
new Float:x1, Float:y1, Float:z1, Float:x2, Float:y2, Float:z2, Float:end_x, Float:end_y, Float:end_z, Float:X, Float:Y, Float:Z, Float:A;
GetVehiclePos(veh, X, Y, Z);
GetVehicleZAngle(veh,A);
new rak = CreateObject(345, X, Y, Z+0.75, 0, 0, A, 300.0);
const Float:fScale = 200.0;
GetPlayerCameraPos(playerid, x1, y1, z1);
GetPlayerCameraFrontVector(playerid, x2, y2, z2);
end_x = x1 + floatmul(x2, fScale);
end_y = y1 + floatmul(y2, fScale);
end_z = z1 + floatmul(z2, fScale);
MoveObject(rak,end_x,end_y,end_z,30.0);
SetTimerEx("Exp", 2200, 0, "d",rak);
}
return 1;
}