|
Jason Ayakashi
Registered User
Join date: 15 Nov 2006
Posts: 11
|
02-19-2007 13:59
Hi, folks. I'm building a game in Second Life that involves a set of stationary objects and one user-controlled object. I want these objects to collide with (and never interpenetrate) each other. Other than that, I don't want them to be subject to physics. Is there a way to do that easily? Currently, I'm approaching the problem by making objects that have no property boxes checked (they aren't Locked, Physical, Temporary, or Phantom) and the user moves the user-controlled object via llTakeControls. I've got "collision_start" and "collision" event handlers on the user-controlled object, but when the user moves their object into one of the stationary ones, neither of those event handlers is triggered. They are triggered when my avatar comes into contact with the object, though. This seems bizarre to me. Why is it not triggered when the objects collide? Once I know objects have penetrated each other, I'm pretty sure I can get them back to a non-penetrated state (based on how things are laid out) but I can't do that if the event never gets triggered.  I'm pretty new to scripting in 2L, so any advice on this approach or suggestions of other possible approaches would be much appreciated. Thanks. Jason
|
|
Lex Neva
wears dorky glasses
Join date: 27 Nov 2004
Posts: 1,361
|
02-20-2007 09:32
You could try using a llSensor(). You'd need to do a short-range sensor for things near you, and then use llGetBoundingBox() on those detected objects to find out whether they interpenetrate your object in question.
I did something basic like this in the (open source) IBM CODESTATION maze API. Check in the "return_to_start" state for the jumping through hoops I do to ensure that one robot doesn't go physical while interpenetrating another. Search for "IBM CODESTATION" sim on the world-map in-world.
|
|
Jason Ayakashi
Registered User
Join date: 15 Nov 2006
Posts: 11
|
02-22-2007 12:10
Thanks for the pointer, Lex! I'll take a look at sensors.
|
|
Gaius Goodliffe
Dreamsmith
Join date: 15 Jan 2006
Posts: 116
|
02-22-2007 20:10
From: Jason Ayakashi This seems bizarre to me. Why is it not triggered when the objects collide? "Collisions" in SL are part of the physics engine. For two things to collide, at least one of them must be physical. (Your avatar is physical, which is why it generates collision events for the objects.) Sensors might be the way to go, but there might be other alternatives, depending on what you mean by you not wanting the objects to be "subject to physics". If you merely don't want them dropping to the ground, it would be pretty easy to make the user controlled object (and only that object) physical, set its buoyancy to 1.0, and move it using llMoveToTarget which is very effective at preventing any sort of drift. But that may or may not be an acceptable solution depending on what you're trying to do.
|