Collisions and linked objects
|
|
Komuso Tokugawa
Registered User
Join date: 3 Mar 2005
Posts: 93
|
07-03-2005 16:40
Hi, Does anyone how collisions operates with linked objects?
example: I have a group of objects that operate ok when something collides with them as individual objects, but when I link them (to make it easier to move/reposition) it looks like the collision system defaults to the base object and name.
Is there anyway around this, or is my setup incorrect for getting collisions on linked objects seperately?
ty, kt
|
|
Catherine Omega
Geometry Ninja
Join date: 10 Jan 2003
Posts: 2,053
|
07-03-2005 18:03
You probably want llPassCollisions. I'm in the middle of documenting its quirks as we speak, so if what's there isn't enough as it is, there should shortly be a table explaining what will happen under which circumstances. Linking is kind of a pain in the ass, to be honest. 
|
|
Bosozoku Kato
insurrectionist midget
Join date: 16 Jun 2003
Posts: 452
|
07-03-2005 18:26
I'd avoid llPassCollisions, unless you just want a generic "[something collided with] this linked set [collided with something]" Make two objects (unique names to help denote which is doing what), put a script in each with a collision() event. Link them. Collide with one, collide with the other. Both respond separately. Toss llPassCollisions(TRUE); into the parent prim's script (state_entry()). Now colliding with the child triggers both the child's script's collision() and the Parent's collision(). So, assuming you have a linked set with "traps" to spring when someone walks on them: main script is in the parent, but you want to know when someone hits steptrap0, steptrap1, steptrap2, which are children. Put a collision() event in each child, then use llMessageLink() to tell the parent a specific child was hit (llPassCollisions() doesn't pass this info, a shame really). Child script: integer nLinkNum; string sLinkName;
default { state_entry() { nLinkNum = llGetLinkNumber(); sLinkName = llGetLinkName(nLinkNum); } collision(integer num) { llMessageLinked(1,nLinkNum, sLinkName, NULL_KEY); } } Parent Script: default { state_entry() { } link_message(integer sender, integer num, string str, key id) { if (num == 2) { llOwnerSay("Something collided with \""+sLinkName+"\"!"); } } } Easy to know that a specific link was collided with (or collided with something). You might use llMinEventDelay() in the children to avoid massive spam, and/or a "bool"/timer routine to avoid spamming the main script (as collision() occurs very rapidly). --Bos
|
|
Christopher Omega
Oxymoron
Join date: 28 Mar 2003
Posts: 1,828
|
07-03-2005 18:53
From: Bosozoku Kato Put a collision() event in each child, then use llMessageLink() to tell the parent a specific child was hit (llPassCollisions() doesn't pass this info, a shame really).
Are you sure about this? I recently had a project that used llPassCollisions that worked fine in this respect. Why wouldn't this script do the same thing as yours do? In the parent: default { state_entry() { llPassCollisions(TRUE); } collision_start(integer totalNum) { integer i; for (i = 0; i < totalNum; ++i) { integer linkNum = llDetectedLinkNumber(i); if (linkNum == 2) { llOwnerSay("Something collided with \"" + llGetLinkName(linkNum) + "\"!"); } } } }
==A sorta confused Chris
|
|
Komuso Tokugawa
Registered User
Join date: 3 Mar 2005
Posts: 93
|
07-03-2005 23:00
ty
|
|
Bosozoku Kato
insurrectionist midget
Join date: 16 Jun 2003
Posts: 452
|
07-04-2005 01:22
Does llPassCollisions() return collisions in link order? I know the Parent is the first object to respond to a collision event, even when it's the child that was collided with. If so then yeah you're method's as solid as mine (mine point being knowing which object in the link set was collided with).
Hrm actually I dunno about your method, I'd have to test. But, assuming a child is collided with, the parent fires off the collision() event, num==1, 1 is the parent link num.
Same if there's 500 objects in the set, bump #500 and the parent still is going to see only 1 collision num, no? Blah, now I'll have to go test cuz I'm curious. :)
--Bos
|
|
Lex Neva
wears dorky glasses
Join date: 27 Nov 2004
Posts: 1,361
|
07-04-2005 08:43
Uh, folks... has no one ever heard of llDetectedLinkNumber()? Try this. Create a link set with, say, 5 prims, spaced out so you can collide with them all and linked together. Put this in the parent prim: default { collision_start (integer num_detected) { llSay(0,"Collision with prim #" + (string)llDetectedLinkNumber(0)); } }
When you collide with each prim, you should see which prim number you hit. llDetectedLinkNumber() works for touch events, too.
|
|
Komuso Tokugawa
Registered User
Join date: 3 Mar 2005
Posts: 93
|
07-04-2005 14:02
cool, that works!
Unfortunately I can't use a linked solution, as the objects need to be close together (ie: not overlapped but seam to seam) and I've found the bounding boxes/spheres overlap leading to multiple object hits.
Ah well...I guess we don't have a way around this?
np, thanks for the help everyone.
|
|
Catherine Omega
Geometry Ninja
Join date: 10 Jan 2003
Posts: 2,053
|
07-04-2005 14:58
From: Komuso Tokugawa Unfortunately I can't use a linked solution, as the objects need to be close together (ie: not overlapped but seam to seam) and I've found the bounding boxes/spheres overlap leading to multiple object hits. Ah well...I guess we don't have a way around this? Yup, make invisible objects that are 0.1m smaller to account for the physics overlap, then link them to bigger, visible objects that occupy the space you see now. As long as your visible objects each have a collision_start event with nothing in them, only the smaller ones will do anything. (And yes, sorry, it's collision_start events without anything in them that you wanted, not llPassCollisions. I figured that out eventually.) 
|
|
Ushuaia Tokugawa
Nobody of Consequence
Join date: 22 Mar 2005
Posts: 268
|
07-04-2005 15:08
From: Lex Neva Uh, folks... has no one ever heard of llDetectedLinkNumber()?
Wonderfully condescending. Great job, especially considering these people are offering their assistance.
|
|
Lex Neva
wears dorky glasses
Join date: 27 Nov 2004
Posts: 1,361
|
07-05-2005 07:49
From: Ushuaia Tokugawa Wonderfully condescending. Great job, especially considering these people are offering their assistance. No. I was actually asking if anyone's ever heard of llDetectedLinkNumber(), because I know I'd gone a long time before learning that trick. It was an honest question.
|
|
Bosozoku Kato
insurrectionist midget
Join date: 16 Jun 2003
Posts: 452
|
07-05-2005 16:10
From: Lex Neva Uh, folks... has no one ever heard of llDetectedLinkNumber()? Damn learn something new every day. How new is that function? New to me! If it's been around since beta I'm gonna kick myself in the ass repeatidly, dunno how I'd have ever missed that. Doh and I'm a double idiot, Chris used it in his example, I didn't even notice. That's what I get for skimming posts.
|
|
Lex Neva
wears dorky glasses
Join date: 27 Nov 2004
Posts: 1,361
|
07-06-2005 08:08
From: Bosozoku Kato Doh and I'm a double idiot, Chris used it in his example, I didn't even notice. That's what I get for skimming posts.
Eek, if you're a double idiot, that makes me a triple idiot for not noticing it as well. D'oh.
|
|
Escort DeFarge
Together
Join date: 18 Nov 2004
Posts: 681
|
10-16-2005 10:00
Except... now it seems that.... default { state_entry() { llVolumeDetect(TRUE); } // collision_start(integer number) { llOwnerSay("link " + (string)llDetectedLinkNumber(0)); } }...consistently returns "link 0" which ever prim you hit.
_____________________
http://slurl.com/secondlife/Together
|
|
Escort DeFarge
Together
Join date: 18 Nov 2004
Posts: 681
|
10-17-2005 09:54
From: Christopher Omega Are you sure about this? I recently had a project that used llPassCollisions that worked fine in this respect. Why wouldn't this script do the same thing as yours do? In the parent: default { state_entry() { llPassCollisions(TRUE); } collision_start(integer totalNum) { integer i; for (i = 0; i < totalNum; ++i) { integer linkNum = llDetectedLinkNumber(i); if (linkNum == 2) { llOwnerSay("Something collided with \"" + llGetLinkName(linkNum) + "\"!"); } } } }
==A sorta confused Chris I would check that this still works, Chris. It doesn't for me (yes, even with the forgotten llVolumeDetect..  )
_____________________
http://slurl.com/secondlife/Together
|
|
DoteDote Edison
Thinks Too Much
Join date: 6 Jun 2004
Posts: 790
|
04-07-2006 00:11
I really hate to revive an old thread, but is this busted now? I mean, I can't for the life of me get a VolumeDetect() child prim to even acknowledge being collided with. It seems there's no longer any way to have a a VolumeDetect() prim detect a collision within a linked set. Am I wrong?
Here's the goal.. three linked prims... 1 and 2 are targets, 3 is the processor and they are all linked. Make 3 recognize the unique collisions of 1 and 2. Possible?
|