|
Bree Giffen
♥♣♦♠ Furrtune Hunter ♠♦♣♥
Join date: 22 Jun 2006
Posts: 2,715
|
01-09-2007 09:37
I was wondering if there is a way to replace the z value in a vector. Here is my example code: default { state_entry() { llVolumeDetect(TRUE); }
collision_start(integer num_detected) { llRezObject("box", llDetectedPos(0), <0,0,0>, ZERO_ROTATION, 5); } }
I basically want an avatar to fall through a floor shaped prim of dimension 10x10x0.5. The floor contains the code above. I want to rez a box on the floor at the xy position where the avatar has landed. The problem with my code is that the box is rezzing at the correct xy but the z is usually 1-3 meters above the floor. Is there any kind of vector arithmetic that I can use to basically strip the z value from the llDetectedPos vector and replace it with a specific value?
|
|
Senuka Harbinger
A-Life, one bit at a time
Join date: 24 Oct 2005
Posts: 491
|
01-09-2007 09:42
one thing to remember with llDectedPos() is that it returns the center of the of the object (I think it's geometric center, but it might also be the center of the root prim or center of the mass). what you need to do is something like the following: default { state_entry() { llVolumeDetect(TRUE); }
collision_start(integer num_detected) { vector mypos=llGetPos(); vector targetpos=llDetectedPos(0); llRezObject("box", <targetpos.x,targetpos.y,mypos.z +.25>, <0,0,0>, ZERO_ROTATION, 5); } }
this will Rez your object .25m above the middle of the floor's Z axis, and right at the detected x and y coordinates. you might want to use llRezAtRoot instead since llRezObject works from the center of mass, which may not be the geometric center.
_____________________
My SLExchange shopTypos are forgiven; desecrating the english language with reckless abandon and necrophilic acts is not. The function is working perfectly fine. It's just not working the way you wanted it to work.
|
|
Ziggy Puff
Registered User
Join date: 15 Jul 2005
Posts: 1,143
|
01-09-2007 09:43
You can address the individial values in a vector with .x/y/z. vector newVec = llDetectedPos(0); newVec.z = something; llRezObject( ... newVec, ...);
|
|
Bree Giffen
♥♣♦♠ Furrtune Hunter ♠♦♣♥
Join date: 22 Jun 2006
Posts: 2,715
|
01-09-2007 14:56
Wow. Thanks! I'll try this out tonight.
|