Jump to content

Detecting Water vs Ground, and if an object is in the way?


Ruthven Ravenhurst
 Share

You are about to reply to a thread that has been inactive for 2263 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

I'm working out in my head (haven't tried to actually script it yet) how you would determine if say 5 meters in front of you, if there's water, ground or an object blocking the 2. I'm wanting to create an attachment that only works when standing near water, as long as there isn't an object or ground in the way.

I've already gathered that using llWater and llGround will tell you which is higher, and so if water is higher, then water is near. But then what about objects? llCastRay?

and of course, prim water is a whole different story

Link to comment
Share on other sites

I have scripted vehicles that use a combination of llGround, llWater and llCastRay to tell whether they are over water, land, or a bridge, and thus change their behavior. It sounds like that close to what you are hoping to do. The big difference seems to be between being over water and being near it. One clumsy way to approach the problem might be to attach a transparent phantom sensor, or use a follower, that lives 5m in front of you, always pinging straight down with llCastRay.  As long as you only care about what's "near" and directly in front of you, that should work.

Link to comment
Share on other sites

1 hour ago, Rolig Loon said:

One clumsy way to approach the problem might be to attach a transparent phantom sensor, or use a follower, that lives 5m in front of you, always pinging straight down with llCastRay.  As long as you only care about what's "near" and directly in front of you, that should work.

You don't need a scanner object.  I do something similar (to prevent pathfinding critters from trying to enter Linden water) and use something like this

vector vOffset = <5.0,0.0,0.0>;
rotation rRot = llGetRot();
vector v = llGetPos() + vOffset * rRot;//five metres in front of me
float fGround = llGround(vOffset * rRot);
float fWater = llWater(vOffset * rRot);
  
list temp = llCastRay(v, <v.x, v.y, v.z - 5.0>,[RC_MAX_HITS,1,RC_DETECT_PHANTOM,FALSE]); //cast ray from 5 metres in front of me to 5 metres in front of, and below, me
if(llList2Integer(temp,-1) == 1 && llList2Key(temp,0)==NULL_KEY){
  	 //whatever I detected was either the ground or linden water
   	 //compare fGround and fWater to decide which it is
  }
  

 

  • Like 3
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 2263 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...