Jump to content

Detecting collisions


d0ublE

Recommended Posts

I've been working on having an object move to a location, that has obstacles in the way. I am using MovetoTarget to move my cube from start position to its target position. I have tried both the collision() and collision_start() events to try and sense when it runs into obstacles, but when  it does it just runs into it and gets stuck. Also I tested to see if the collision events were even being entered and they weren't. So I was just wondering if anyone had any advice on having an object move around obstacles on it's way to it's target destination.

Thanks.

Link to comment
Share on other sites

And you can't just set the object phantom?

llSetStatus(STATUS_PHANTOM, TRUE); or llVolumedetect(TRUE);

Or use non-physical movement?

 

If not I'd first find out why collisions aren't registering. Did you put any llCollisionFilters, and can you paste your collision events? We can't help tooo much without a script to look at.

Link to comment
Share on other sites

There are two challenges.  One is how to detect that the object is stuck, and the other is what to do about it. 

If the object is stuck, you ought to be able to tell by checking its position in a timer event and noticing that it has stayed in almost the same place instead of making progress toward the target.  Deciding what to do is the hard part.  You can't tell ahead of time whether the object should turn left or right (or maybe go up and over) to avoid an obstacle, so there's no guarantee that you can get it unstuck.  Of course you could always script it to TP to the target i it finds itself hopelessly stuck, but that's cheating......

Link to comment
Share on other sites

Phantom is cheating to me. For non-physical movement do you mean turn Physical off and use SetPos() after obtaining the detected target's Pos? Is there a way to control how fast the object moves to that location? It goes too fast. Physical movement using llMovetoTarget allows me to adjust the tau which helps control the speed at which my object moves to a certain place.

Link to comment
Share on other sites


d0ublE wrote:

Phantom is cheating to me. For non-physical movement do you mean turn Physical off and use SetPos() after obtaining the detected target's Pos? Is there a way to control how fast the object moves to that location? It goes too fast. Physical movement using llMovetoTarget allows me to adjust the tau which helps control the speed at which my object moves to a certain place.

Well, anything you do to get past an obstacle is "cheating" in a way.  llMoveToTarget wants to go in a straight line from start to finish, so deviating from that line is cheating too.  Changing the object to phantom at least temporarily is just another way to stay on course. 

The idea of going non-physical briefly and moving with llSetPos is really what I was suggesting as "cheating" in my first reply.  llSetPos has a distance limit of 10m, so you can't use it reliably for this purpose, but you can use WarpPos or PosJump, both of which hack llSetPos to jump large distances.   As far as I can see, that's really your only good option for avoiding obstacles.  As I said before, you have no way of predicting whether your object will need to move left, right, up, or backwards to get out of a bad spot.  The "obstacle" could also be a parcel ban line or a no-script area that would never register a collision and might even disable your object.  The phantom solution would fail in either of those cases too.  It may sound like cheating, but if you really want your object to get to the target, the only reliable solution I can think of is to tell it to TP (WarpPos, PosJump, whatever) when it gets stuck.

Link to comment
Share on other sites

You can use vehicle physics and feeback, possibly. As to how...wow, there is more than one way to do many thing in LSL but sometimes only one or two ways that will give you adaquate  results, from what I read. But you mention tua. Well, you can use linear motors to decay and then work on friction. Now, the friction and linear motors will be affected by collisions causing bouncing(if you are that quick or get hit by something moving) and also by grades/hills. But, you can use a velocity check maybe? Not sure. But if you look into it you might be surpirsed. and you can use feelers to maybe handle any colliding (if you want to move quick) to retract and keep the main bits of you vehciles body out of the way. Heck, attach a few flexy feeler hairs on there to make it all look fuzzy and crazy when it moves! lol. MOre meta, you can see it's means and if you stiffen or skew the feelers you can make them move toward an area and so on. But this is a little slow, kind of maybe a waste But might be good for using less feelers and have one main one and then the others drop to feel when they are needed, so as to avoid constantly getting readings needed. when they collide, the retract back along where they came from and your little vehicle moves. Of course, now your vehicle is a bug looking thing....but who says they need to be feelers from bugs! Lazers, like  infrared! or you could make them invisable with the default transparent texture in everyones inventory!

Now, teh logic and so on...this is all where you have to figure out. But collisions are recorded in movign vehicles. As for what works best? Well, you can make the feelers oscilate if they don't get a recording or simply make the vehicle move faster and then when it bumps retract the feeler and slow the vehicle to a stop. I say simply, but that is an exageratin because I wont script it right here in the forum for you lol. It is a bit of work to get it all working and I am not sure it will all work. Tweaking vehicle phsyics is slightly about balance, one number effects the others because it is using a physics engine. So some trial and error is maybe needed.

First thing to look into for vehicle physics is the Vehicle Tutorial at teh Seocnd LIfe wiki. Then there is the Vehicle Laboritory in world.  Then there is tonnes of time and all of the logic, where to put the feelers and so on. I am not sure you will be able to make this all run smooth, but retracting the feelers and some strong (low number) friction might keep your vehicle from sliding around and bumping way out. Oh, and slow movement!

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...