SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 04/09/2010, 02:39 PM   #1
[XST]O_x
High-roller
 
[XST]O_x's Avatar
 
Join Date: Aug 2009
Posts: 1,960
Reputation: 94
Default Setting an object rotation by the player's camera vector?

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.
[XST]O_x is offline   Reply With Quote
Old 04/09/2010, 02:43 PM   #2
Mauzen
High-roller
 
Mauzen's Avatar
 
Join Date: Jun 2007
Location: Western Germany
Posts: 4,876
Reputation: 1597
Default Re: Setting an object rotation by the player's camera vector?

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));
Mauzen is offline   Reply With Quote
Old 04/09/2010, 02:55 PM   #3
[XST]O_x
High-roller
 
[XST]O_x's Avatar
 
Join Date: Aug 2009
Posts: 1,960
Reputation: 94
Default Re: Setting an object rotation by the player's camera vector?

Thanks a lot! Works just fine.
[XST]O_x is offline   Reply With Quote
Old 14/07/2012, 02:03 PM   #4
Trooper[Y]
Huge Clucker
 
Trooper[Y]'s Avatar
 
Join Date: Apr 2009
Posts: 397
Reputation: 18
Default AW: Setting an object rotation by the player's camera vector?

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]));
__________________




Trooper[Y] is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Object Rotation]Simple but I don't know. BP13 Help Archive 9 07/11/2009 11:01 PM
Setting Player's Current Weapon Haku Help Archive 1 30/08/2009 03:49 AM
Object Rotation Hot Help Archive 1 17/05/2009 02:26 PM


All times are GMT. The time now is 12:55 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.