Setting an object rotation by the player's camera vector?
#1

Well,yes,is it possible?

Since I've tried making it and it was just fucked up.
Maybe I miscalculated something.

This is how I tried to make it however:
pawn Code:
SetObjectRot(missile_object[i],VehCameraPos[i][0]+VehVectorPos[i][0],VehCameraPos[i][1]+VehVectorPos[i][1],VehCameraPos[i][2]+VehVectorPos[i][2]);
There are no problems with the camera vector storing since the explosions are creating correctly:
pawn Code:
CreateExplosion(VehCameraPos[i2][0]+(VehVectorPos[i2][0] * Dist)+OffSet[i2][0],VehCameraPos[i2][1]+(VehVectorPos[i2][1] * Dist)+OffSet[i2][1],VehCameraPos[i2][2]+(VehVectorPos[i2][2] * Dist)+OffSet[i2][2],7,100);
So the problem is in SetObjectRot, is there any way of solving this issue? Or at least any alternatives would be highly appreciated.

And sorry, this is the first time I'm messing with camera vectors.
Reply
#2

Yeah, this is quite annoying, because object rotation and stuff like atan do not always use the same scales.
It should work like this, took me a while to get the right offsets, but i needed it for a fs:

SetObjectRot(object, asin(z_vector), 0.0, 360 - atan2(x_vector, y_vetor));
Reply
#3

Thanks a lot! Works just fine.
Reply
#4

As i have that problem too,
i tested that code but it doesnt change the rotation of the (attached) object:

new Float:tfx[6];
GetPlayerCameraFrontVector(playerid, tfx[0],tfx[1],tfx[2]);
SetObjectRot(gunobj, asin(tfx[2]), 0.0, 360 - atan2( tfx[0], tfx[1]));
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)