Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Terrible with math, need some help with rotations and velocity.

Charlotte Wirtanen
Registered User
Join date: 6 Dec 2006
Posts: 15
01-28-2007 19:30
I'm currently scripting a gun system and I'm having some issues with the shell ejection. With the gun positioned correctly on the x-axis, the ejection works fine; the shell is rezzed and flung up and backwards along the x-axis.

However, when the gun is rotated in any way a problem appears, the shell is still ejected as if the gun were perfectly aligned and stationary.

I'm aware that this is due to the velocity parameter on llRezObject but I'm not even sure where to start calculating to always make the shells fly out in the right direction..

Here's my current code:

CODE

vector vRezPoint;

vRezPoint = llGetPos();
vRezPoint.x += 0.10;
vRezPoint.z += 0.10;

llRezObject("shell", vRezPoint, <2,0,0>, llGetRot(), 1);
Charlotte Wirtanen
Registered User
Join date: 6 Dec 2006
Posts: 15
01-28-2007 20:40
Figured it out.

For those wondering, the correct method is:

CODE

vector vRezPoint;
vector vRezVel;

vRezPoint = llGetPos();
vRezPoint.z += 0.05;

vRezVel = <0,2,-1> / llGetRot();

llRezObject("shell", vRezPoint, vRezVel, llGetRot(), 1);