08.08.2010, 07:09
(
Последний раз редактировалось Simon; 08.08.2010 в 10:53.
Причина: Clarified my post a little bit
)
A vector is not a position which is what CreateObject expects. You have to use a combination of GetPlayerCameraPos and GetPlayerCameraFrontVector.
For example you could do something like this to create an object in the direction of where a player is looking.
You'll have to read about vector algebra if you wish to do more.
For example you could do something like this to create an object in the direction of where a player is looking.
pawn Код:
new
Float:fPX, Float:fPY, Float:fPZ,
Float:fVX, Float:fVY, Float:fVZ,
Float:object_x, Float:object_y, Float:object_z;
// Change this constant to the the scale you want. A larger scale increases the distance from
// the camera. A negative scale will inverse the vectors and make them face in the opposite
// direction (i.e. behind the camera)
const
Float:fScale = 6.0;
GetPlayerCameraPos(playerid, fPX, fPY, fPZ);
GetPlayerCameraFrontVector(playerid, fVX, fVY, fVZ);
object_x = fPX + floatmul(fVX, fScale);
object_y = fPY + floatmul(fVY, fScale);
object_z = fPZ + floatmul(fVZ, fScale);
CreateObject(345, object_x, object_y, object_z, 0.0, 0.0, 0.0);