Help: Collision Event
|
Seagel Neville
Far East User
Join date: 2 Jan 2005
Posts: 1,476
|
04-09-2005 23:14
Hello there,  I'm still stuck wiht this.... I got the following script thanks to your help. When I say, "start", it moves up and down until I say, "stop". default { on_rez(integer n) { llResetScript(); } state_entry() { llListen( 0, "", NULL_KEY, "" ); } timer() { llSetPos(llGetPos() + (<0,0,2> * llGetRot())); llSleep(2.0); //Any time you like llSetPos(llGetPos() - (<0,0,2> * llGetRot())); llSleep(2.0); //Any time you like } listen( integer channel, string name, key id, string message ) { if ( message == "start" ) { llSetTimerEvent(1); } else if ( message == "stop" ) { llSetTimerEvent(0); } } }
Now, I rez a new object which is named "JUST_A_BOX" in the way of its movement. And I'd like to make the scripted object say, "JUST_A_BOX bumped me!" when it bumps against the new object. In short, I'd like to insert the folloing event into the above script, but I don't know where and how I should do. Please help me. collision_start(integer num_detected) { llSay(0, llDetectedName(0) + " bumped me!"); }
|
Jeffrey Gomez
Cubed™
Join date: 11 Jun 2004
Posts: 3,522
|
04-09-2005 23:23
Create a new script in the object with this: default { collision_start(integer num_detected) { llSay(0, llDetectedName(0) + " bumped me!"); } }
Problem solved! 
_____________________
---
|
Seagel Neville
Far East User
Join date: 2 Jan 2005
Posts: 1,476
|
04-10-2005 00:15
Hi Jeffrey, thanks for this quick response. I've not noticed such a thing for over two weeks. I tried this, but I'm afraid it said nothing. When I bumped it, it said, "Seagel Neville bumped me!". But when the new object was bumped, it said nothing. And when I sat on the new object and was bumped, it said nothing. I don't know why... help. Edit  ome typo, sorry
|
Jeffrey Gomez
Cubed™
Join date: 11 Jun 2004
Posts: 3,522
|
04-10-2005 00:53
Odd. Try replacing "collision start" with "collision" and see what happens.
_____________________
---
|
Seagel Neville
Far East User
Join date: 2 Jan 2005
Posts: 1,476
|
04-10-2005 05:47
I tried that, but failed. It wasn't different at all. Throwing myself against that moving screpted object, it said what I expected, "Seagel Neville bumped me!". But standing and waiting for getting hit by the object, it said nothing even though I got hit. I tried to place the up-and-down script into one object, and the collision script into the both. That didn't work, either. I tried to place the resting object on ground and set it as physic. And I set up the moving object above the resting one so that it might be hit. it didn't work. When I changed, however, the moving one's mode to physic, it fell down and hit and said what I expected again and again. but that's all. It never moved again. It was my first time that I heard it say about another object, not my name though. 
|
Kali Dougall
Purple and Spikey
Join date: 5 Feb 2005
Posts: 98
|
04-10-2005 06:42
I believe objects moved with llSetPos don't fire collision events.
|
Catherine Omega
Geometry Ninja
Join date: 10 Jan 2003
Posts: 2,053
|
04-10-2005 07:14
From: Kali Dougall I believe objects moved with llSetPos don't fire collision events. That's correct -- objects must be physical to collide with something.
|
Seagel Neville
Far East User
Join date: 2 Jan 2005
Posts: 1,476
|
04-10-2005 09:11
Eek! Thank you, Kali and Catherine,
hmm I've got to consider another way...
|
Jeffrey Gomez
Cubed™
Join date: 11 Jun 2004
Posts: 3,522
|
04-10-2005 12:57
Whoops! Didn't catch that. Thanks. As for another way, try llVolumeDetect.
_____________________
---
|
Seagel Neville
Far East User
Join date: 2 Jan 2005
Posts: 1,476
|
04-11-2005 22:06
Hi Jeffrey, I heard a lot of ppl say,"Use llVolumeDetect", but I didn't understand how to use it because the example of wiki was too poor for me, a beginner to use. Example: llVolumeDetect(TRUE); // turns llVolumeDetect on. Is this really an exapmle??How can I use this? OK, anyway, I took this meaned that it would turn to be TRUE when something was bumped. Yeah, I know I'm wrong, but I don't know what to do... integer bump; default { on_rez(integer n) { llResetScript(); } state_entry() { llListen( 0, "", NULL_KEY, "" ); llVolumeDetect(bump); } timer() { llSetPos(llGetPos() + (<0,0,2> * llGetRot())); if(bump = TRUE) { llSay(0, llDetectedName(0) + " bumped me!"); } else { llSay(0, llDetectedName(0) + " hehe"); } llSleep(2.0); llSetPos(llGetPos() - (<0,0,2> * llGetRot())); if(bump = TRUE) { llSay(0, llDetectedName(0) + " bumped me!"); } else { llSay(0, llDetectedName(0) + " hehe"); } llSleep(2.0); } listen( integer channel, string name, key id, string message ) { if ( message == "start" ) { llSetTimerEvent(1); } else if ( message == "stop" ) { llSetTimerEvent(0); } } } It always said,"00000000-0000-0000-0000-000000000000 bumped me!" even though nothing bumped. Please help 
|
Kali Dougall
Purple and Spikey
Join date: 5 Feb 2005
Posts: 98
|
04-12-2005 09:26
llVolumeDetect() is a property on an object. It lasts from when a script turns it on to when it gets turned off. Basically it makes the object phantom and then fires collision events for other objects interpenetrating it, regardless (I believe) of how they got there. Useful for door sensors and such. So what you want to do is stick llVolumeDetect(TRUE) in default state_entry of the bumpee object, not the bumper. Then give it a collision_start event and the bumper should fire it whenever it interpenetrates. Also, even though your code example doesn't pertain to the actual function, I must point out: if(bump = TRUE) = is an assignment operator, == is a comparison operator. Be very careful. Good luck!
|
Seagel Neville
Far East User
Join date: 2 Jan 2005
Posts: 1,476
|
04-13-2005 07:36
Hello Kali, Thanks for replying.  From: Kali Dougall So what you want to do is stick llVolumeDetect(TRUE) in default state_entry of the bumpee object, not the bumper. Then give it a collision_start event and the bumper should fire it whenever it interpenetrates. Yep, the bumpee object, not the bumper. I got it. So I put down the following and put it into the bumpee object. default { state_entry() { llVolumeDetect(TRUE); } collision(integer num_detected) { llSay(0, llDetectedName(0) + " bumped me!"); } }
It didn't work at all, though it turned to be phantom. I was not sure, but I changed it to the following. default { collision(integer num_detected) { llVolumeDetect(TRUE); llSay(0, llDetectedName(0) + " bumped me!"); } }
Yeah, it said once when I bumped it. So I put the Function, "llResetScript();" after "llSay" on it. I thought it was perfect. But I failed.  It said nothing when another object which had above up-down script bumped it. Sad...  From: someone = is an assignment operator, == is a comparison operator. Be very careful. Certainly.
|