Help with objects rezzing objects
|
|
Cyrus Odets
Registered User
Join date: 5 Oct 2005
Posts: 51
|
02-23-2006 12:44
Hi there,
I've got an object that, when given a command, rezzes another object into the world. Setting the rezzed object location in the x,y plane is no problem...its the z plan (altitude) that is giving me a few problems. The object that is rezzing the second object is a HUD attachment, and as such, the object that it rezzes ends up popping into the world at about waste-height on the avatar....instead of flat on the ground as I want it to be.
I thought perhaps I could turn physics ON...on the object to let it fall to the ground...and then turn physics back off again. Its the first time I'd messed with physics yet though and, to my dismay, I've found that with physics on...the rezzed object doesn't quite sit 'flat' on the ground...instead it sort of 'hovers' a couple inches above the ground. That MAY not be that big a deal as its only really noticeable if you're looking for it...so using the 'physics' on/off thing might still be my best bet.
The other option I explored was getting the Bounding Box of the avatar wearing the HUD attachment...and feeding those numbers to the object spawned to use THAT to calculate where the true 'ground' or 'floor' level should be. That works...but it seems a REALLY over-complicated solution to something that seems like there must be a better way to do it.
So my question is.....What do you think the 'best' way to do this is? I'm sure I'm overcomplicating this and making a mountain out of a molehill.
Thanks!
-- Cy
|
|
Eggy Lippmann
Wiktator
Join date: 1 May 2003
Posts: 7,939
|
02-23-2006 13:09
I suppose you're looking for a little function called llGround http://secondlife.com/badgeo/wakka.php?wakka=llGround
|
|
Harris Hare
Second Life Resident
Join date: 5 Nov 2004
Posts: 301
|
02-23-2006 13:19
Just use llGround(vector offset) to detect the height of the ground at the spot you want to rez it. Since the script doing the rezzing is a HUD, the offset will need to be a vector away from your avatar's position. The following code is untested but what it does is rez the object on the ground one meter in the direction of x from you. It calculates the correct height by first finding out what the height of the ground at that position is and then adding half the height of your object (which you will need to provide beforehand otherwise your object will rez halfway in the ground). For example, if your object is 2 meters tall: string objectName = "Example"; //Name of the object
float objectHeight = 1; //Half the height of the object
vector objectPos = llGetPos() + <1,0, (llGround(<1,0,0>) + objectHeight)>;
llRezObject(objectName, objectPos, ZERO_VECTOR, ZERO_ROTATION, 0);
|
|
Harris Hare
Second Life Resident
Join date: 5 Nov 2004
Posts: 301
|
02-23-2006 13:26
I should mention that the above code will only work if you are within 10 meters of the ground.
If what you really want is to just rez the object near your avatar's feet (not really on the ground... you could be standing on a platform) then use the llGetAgentSize(key id) function to find out your height and subtract half.
|
|
InuYasha Meiji
Half Demon
Join date: 14 Mar 2005
Posts: 127
|
coundn't get it to work
06-06-2006 16:56
From: Harris Hare Just use llGround(vector offset) to detect the height of the ground at the spot you want to rez it. Since the script doing the rezzing is a HUD, the offset will need to be a vector away from your avatar's position. The following code is untested but what it does is rez the object on the ground one meter in the direction of x from you. It calculates the correct height by first finding out what the height of the ground at that position is and then adding half the height of your object (which you will need to provide beforehand otherwise your object will rez halfway in the ground). For example, if your object is 2 meters tall: string objectName = "Example"; //Name of the object
float objectHeight = 1; //Half the height of the object
vector objectPos = llGetPos() + <1,0, (llGround(<1,0,0>) + objectHeight)>;
llRezObject(objectName, objectPos, ZERO_VECTOR, ZERO_ROTATION, 0); I need to rez objects on the ground, and I can't seem to get it to work. Someone please help.
|
|
Angela Salome
Registered User
Join date: 6 Oct 2005
Posts: 224
|
06-06-2006 22:25
From: InuYasha Meiji I need to rez objects on the ground, and I can't seem to get it to work. Someone please help. Can you show us your script and tell us more about the context the script is operating in please?
|
|
Haravikk Mistral
Registered User
Join date: 8 Oct 2005
Posts: 2,482
|
06-07-2006 03:43
If you are more than 10m from the ground then it won't rez there (you can only rez up to 10m), so the object you create will need to have a script inside it that will move it the rest of the way.
_____________________
Computer (Mac Pro): 2 x Quad Core 3.2ghz Xeon 10gb DDR2 800mhz FB-DIMMS 4 x 750gb, 32mb cache hard-drives (RAID-0/striped) NVidia GeForce 8800GT (512mb)
|
|
InuYasha Meiji
Half Demon
Join date: 14 Mar 2005
Posts: 127
|
Not working.
06-07-2006 04:23
From: Angela Salome Can you show us your script and tell us more about the context the script is operating in please? I just took the script that was posted here and just for test purposes placed it in the default script that says hello avatar to make it so I click the box to place a flowering plant I created on the ground under the box, only one meter above. But nothing appears. default { state_entry() { llSay(0, "Touch me for flower, Avatar!"  ; } touch_start(integer total_number) { llSay(0, "Touched."  ; string objectName = "Crocus"; //Name of the object float objectHeight = 0.204; //Half the height of the object vector objectPos = llGetPos() + <0,0, (llGround(<0,0,0>  + objectHeight)>; llRezObject(objectName, objectPos, ZERO_VECTOR, ZERO_ROTATION, 0); } }
|