Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Rezzing and moving a projectile BEHIND an avatar.

Wildefire Walcott
Heartbreaking
Join date: 8 Nov 2005
Posts: 2,156
04-09-2007 11:28
I have an attachment that needs to rez and move a projectile behind an avatar. I've looked at gun scripts (which all rez/move the projectile in front of an avatar, as you would expect) and they use llGetRot to get the direction the avatar's facing and then use llRot2Up to get the vector representing a straight line away from the avatar.

I've tried tweaking the results of these functions to sort of get the opposite position and vector (for example, multiplying x, y, and z of the Rotation by -1 before passing to llRot2Up), but my results have been very bizarre. For example, if I calculate the inverse of the forward vector, my attachment correctly fires the projectile behind me if I'm facing North or South, but fires it in front of me if I'm facing East or West!

What is the proper method for determining a rezzing offset that would position an item behind the avatar, and a vertex that would move the object in that direction? Keep in mind this is for an attachment, so the functions for getting position/rotation work a little differently for standalone objects, to my understanding.

For extra credit, does the local rotation of the attachment mean anything at all? In my tests I've noticed that the projectile doesn't move on a flat plane. The thing will fire higher and further if I'm facing in one direction than it will in another direction, as if its movement plane is tilted down... rotating the attachment doesn't appear to have an effect on this, but I can't tell for sure.
_____________________
Desperation Isle Estates: Great prices, great neighbors, great service!
http://desperationisle.blogspot.com/

New Desperation Isle: The prettiest BDSM Playground and Fetish Mall in SL!
http://desperationisle.com/

Desperation Isle Productions: Skyboxes for lots (and budgets) of all sizes!
Twisted Pharaoh
if ("hello") {"hey hey";}
Join date: 24 Mar 2007
Posts: 315
04-09-2007 12:16
Something along that line, I guess:

CODE

rotation rot ;
vector velocity = <1.0, 0.0, 0.0> ; // dummy values
vector pos = <-0.2,0.0, 0.0> ; // offset of the bullet with no rotation

rot = llGetRot() + <0.0,0.0,PI,1.0>;
bulletpos = llGetPos()+pos*(ZERO_ROTATION/ rot) ;
llRezAtRoot("Bullet", bulletpos, velocity, ZERO_ROTATION/rot, 0) ;


It is the basic idea I've never rezzed anything with a velocity so it might not work that well and geometry is not my cup of tea anyway.
Wildefire Walcott
Heartbreaking
Join date: 8 Nov 2005
Posts: 2,156
04-09-2007 12:42
From: Twisted Pharaoh
CODE

rotation rot ;
vector velocity = <1.0, 0.0, 0.0> ; // dummy values
vector pos = <-0.2,0.0, 0.0> ; // offset of the bullet with no rotation

rot = llGetRot() + <0.0,0.0,PI,1.0>;
bulletpos = llGetPos()+pos*(ZERO_ROTATION/ rot) ;
llRezAtRoot("Bullet", bulletpos, velocity, ZERO_ROTATION/rot, 0) ;


It is the basic idea I've never rezzed anything with a velocity so it might not work that well and geometry is not my cup of tea anyway.

Wow, I certainly wouldn't have come up with that on my own! Will try it out tonight. Yeah, I think this might be the first time in my life I regretted not paying much attention in Geometry. Physics regret is on the horizon, I fear.
_____________________
Desperation Isle Estates: Great prices, great neighbors, great service!
http://desperationisle.blogspot.com/

New Desperation Isle: The prettiest BDSM Playground and Fetish Mall in SL!
http://desperationisle.com/

Desperation Isle Productions: Skyboxes for lots (and budgets) of all sizes!