llPushObject force direction? For rocket launcher thingie
|
|
Mandy Marseille
Registered User
Join date: 13 Oct 2006
Posts: 30
|
09-25-2007 01:10
Hey all, I'd like to shoot a 'bullet' from a platform, like a rocket launched from ground with llPushObject. (Using this is a MUST, no llApplyImpulse etc.) My problem is, that the rotation of the launcher along the Z axis.. 0-90 deg goes into the formula of llPush. llPushObject(key id, vector impulse, vector angular_impulse, integer local) Like for impulse I calculate as (example): <0,1,1> * llGetRot() * llGetMass() But if the Z rotation for launcher (or rocket) is 90 degrees, this will result in <0,1,1> * <x,y,90>*llGetMass() like this:  | |___ o==o and with 45 degrees <0,1,1> * <x,y,45>*llGetMass() / /___ o==o So in the end, shooting at 90 degrees will make the rocket receive twice the amount of push, thus making it fly twice as fast (I'm not sure about it) but I would like it to fly with the same speed in all times. I just don't understand, why isn't there a separate direction and force vector. Maybe I'm missing something and it's my first Push thingie anyway, please help meeeee. 
|
|
Qie Niangao
Coin-operated
Join date: 24 May 2006
Posts: 7,138
|
09-25-2007 03:15
Does this actually generate different speeds? Rotating a vector should retain the magnitude of the vector, so it's not clear what's going on here. I might use llVecNorm(<0,1,1>  just so I was dealing with a unit vector (otherwise the magnitude will be square root of 2). (And the rotation will be a quaternion, not a vector, and radians instead of degrees would apply to the Euler representation of that rotation, but the 90 and 45 may just be shorthand in the post since llGetRot just returns a rotation.) As to why there's not a separate direction and force vector... a force has direction (which you could get by llVecNorm(forceVector)) and magnitude (llVecMag(forceVector)). If the script has separately the direction unit vector and the magnitude scalar, it can just multiply them to get the force vector.
|
|
nand Nerd
Flexi Fanatic
Join date: 4 Oct 2005
Posts: 427
|
09-25-2007 06:14
Qie is right, might I add that understanding how to put this together isn't as hard as it sounds. Say you have an object you want to push along it's x axis, you'd multiply the force by <1,0,0> to give your force a direction. So say you had a force of 99 and your object is to fly along it's x axis, the result of 99 * <1,0,0> would be <99,0,0>, the force and direction. Now, thats okay if the object isn't rotated. If it is, then we can simply rotate the force vector to the global coordinates (i.e. instead of 99 along the x axis LOCALLY, we're talking 99 down a unique axis GLOBALLY). So we'll do that by multiplying our force vector <99,0,0> by llGetRot(). When we do this the overall force is still 99 but it's angled to suit the region's axis. In essence we're saying (float/integer)force * (vector)localaxis * (rotation)rotationofobject Hope this helps, feel free to correct me if I'm wrong 
_____________________
www.nandnerd.info http://ordinalmalaprop.com/forum - Ordinal Malaprop's Scripting Forum
|
|
Mandy Marseille
Registered User
Join date: 13 Oct 2006
Posts: 30
|
09-25-2007 07:27
Thank you guys, as soon as I'm home, I will try the suggested ideas. 
|
|
Lee Ponzu
What Would Steve Do?
Join date: 28 Jun 2006
Posts: 1,770
|
Two common mistakes...
09-25-2007 09:32
<x,y,45> is not a rotation, it is a vector.
Also, angles are in radians, not degrees.
|
|
Mandy Marseille
Registered User
Join date: 13 Oct 2006
Posts: 30
|
09-25-2007 11:01
Thanks, I know that's a vector, I just skipped the llRot2Euler and RAD_TO_DEG conversion in the example.
Also, I think I will need functions like llRot2Up etc.
|
|
Shadow Subagja
Registered User
Join date: 29 Apr 2007
Posts: 354
|
09-25-2007 14:10
multiplying by a rotation (ie llGetRot()) rotates the vector, it doesn't do a scalar multiply or anything like that. The rotations are quaternions (x,y,z,s) and the multiply operator between the two does a rotation transform.
I think you won't have the problem you expect with angle magnitudes causing velocity changes.
|