|
Teap Tomsen
Registered User
Join date: 26 Nov 2007
Posts: 9
|
07-04-2008 00:06
I'm new to scripting so I'm having a hard time finding what I'm doing wrong... if you tell me what is wrong with this tiny chunk of script I will learn more than you can imagine. What it is supposed to do is simply place the object directly on top of the ground... however it doesn't seem to have any effect. default { state_entry() { float GroundHeight = llGround(<0,0,0>); vector posi = llGetPos(); float sub = posi.z -= GroundHeight; posi.z = posi.z -= sub; llSetPos(posi); } }
|
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
07-04-2008 00:41
I'm not sure exactly what the last three lines are trying to do, but they can be simplified a great deal: default { state_entry() { float GroundHeight = llGround(<0,0,0>); vector posi = llGetPos(); posi.z = GroundHeight; llSetPos(posi); } }
Note that llSetPos() can only move a distance of 10m or less. Any attempt to move farther than that will result in the object moving in the direction of the target, but only by 10m not the full distance. You might want to do a search on "WarpPos" to see a common solution to this problem.
|
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
07-04-2008 00:46
Oh, and note that you may have to add a small value to the z coordinate to put the object "on the ground", since setting the object's z coordinate equal to the ground height will put the MIDDLE of the root prim at ground level (also SL may not accept positions at or below ground level; another potential reason to add a small bit to the height).
|
|
Dora Gustafson
Registered User
Join date: 13 Mar 2007
Posts: 779
|
07-04-2008 00:57
1. You are finding gound level at the south west corner of your region. You probably want it at your current position: llGround( llGetPos() ); 2. llSetPos() will not move your object more than 10 m 3. llSetPos will not move your object below ground level 4. your calculations are black magic to me  Read all about it: http://www.lslwiki.net/lslwiki/wakka.php?wakka=llSetPos
_____________________
From Studio Dora
|
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
07-04-2008 01:10
From: Dora Gustafson 1. You are finding gound level at the south west corner of your region. You probably want it at your current position: llGround( llGetPos() ); Actually that bit was correct. The argument to llGround() is relative to the prim's current position (I hate how inconsistent the library is about that). See http://www.lslwiki.net/lslwiki/wakka.php?wakka=llGround
|
|
Dora Gustafson
Registered User
Join date: 13 Mar 2007
Posts: 779
|
07-04-2008 01:52
From: Hewee Zetkin Actually that bit was correct. My mistake... new brain... more sugar... 
_____________________
From Studio Dora
|