Visible or invisible?
|
GuanPeng Woodrunner
Registered User
Join date: 12 Jul 2009
Posts: 11
|
09-05-2009 10:40
hi everybody, I need to make a code that allows avisible ball to become invisible after 20 seconds, and it will revert back to visible mode and goes back to invisible. The code is as follows, but I just seem to be unable to figure out the error. Can any kind soul help? float randMove = 20.0; integer OnOff = 1; bounce() { llSetForceAndTorque(llGetMass() * < llFrand(randMove) - randMove / 2 , 0 , 0 >, <1.0,1.0,1.0>, FALSE); llSetTimerEvent(20.0); }
default { state_entry() { llSetStatus(STATUS_PHYSICS, TRUE); }
collision(integer total_number) { bounce(); } timer() { if(OnOff) llSetAlpha(0.0, ALL_SIDES);//makes the prim invisible else llSetAlpha(1.0, ALL_SIDES);//makes the prim visible
OnOff = !OnOff; state default; } }
|
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
|
09-05-2009 10:45
From: GuanPeng Woodrunner hi everybody, I need to make a code that allows avisible ball to become invisible after 20 seconds, and it will revert back to visible mode and goes back to invisible. The code is as follows, but I just seem to be unable to figure out the error. Can any kind soul help? float randMove = 20.0; integer OnOff = 1; bounce() { llSetForceAndTorque(llGetMass() * < llFrand(randMove) - randMove / 2 , 0 , 0 >, <1.0,1.0,1.0>, FALSE); llSetTimerEvent(20.0); }
default { state_entry() { llSetStatus(STATUS_PHYSICS, TRUE); }
collision(integer total_number) { bounce(); } timer() { if(OnOff) llSetAlpha(0.0, ALL_SIDES);//makes the prim invisible else llSetAlpha(1.0, ALL_SIDES);//makes the prim visible
OnOff = !OnOff; state default; } }
one thing, you're never exiting the default state, so you don't need to put the state changing function in there. and another thing, each time the ball bounces, the count is started over, it looks like you're making the ball bounce continuously too, so because the count is started over each time, it never reaches the timer event
|
GuanPeng Woodrunner
Registered User
Join date: 12 Jul 2009
Posts: 11
|
09-05-2009 11:08
so how should i go about editing the code? I am clueless about it. And yes, I want to make it bounce infinitely. Would there be any problem if I were to make it move infinitely? 
|
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
|
09-05-2009 12:03
From: GuanPeng Woodrunner Would there be any problem if I were to make it move infinitely?  depends how long you actually have it rezzed. physics can lag a sim, constantly moving objects with or without physics can lag a sim, and then switching between visible and invisible 3 times a minute can do it's own damage, but not as much i haven't tested any of these. but i move the llSetTimerEvent to the state entry, and took out the state changing function that wasn't needed float randMove = 20.0; integer OnOff = 1; bounce() { llSetForceAndTorque(llGetMass() * < llFrand(randMove) - randMove / 2 , 0 , 0 >, <1.0,1.0,1.0>, FALSE); }
default { state_entry() { llSetTimerEvent(20.0); llSetStatus(STATUS_PHYSICS, TRUE); }
collision(integer total_number) { bounce(); } timer() { if(OnOff) llSetAlpha(0.0, ALL_SIDES);//makes the prim invisible else llSetAlpha(1.0, ALL_SIDES);//makes the prim visible
OnOff = !OnOff; } }
|
Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
|
09-06-2009 10:36
I had a play with this yesterday, and I think that using the collision() rather than collision_start() event is going to cause problems, since the bounce() function is being called constantly -- stick llOwnerSay("bouncing"  ; into the collision event and you'll see what I mean. I'm also not sure which plane it's supposed to bounce in.. as it is, it just shoots along the ground, since it bounces on the x axis.
|
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
|
09-06-2009 11:49
From: Innula Zenovka I had a play with this yesterday, and I think that using the collision() rather than collision_start() event is going to cause problems, since the bounce() function is being called constantly -- stick llOwnerSay("bouncing"  ; into the collision event and you'll see what I mean. I'm also not sure which plane it's supposed to bounce in.. as it is, it just shoots along the ground, since it bounces on the x axis. yeah, i noticed it was on the X axis yesterday, changed it to the Z axis, and it didn't seem to do anything. i didn't noticed that it was collision, and not collision start, that's probably why it didn't work
|
GuanPeng Woodrunner
Registered User
Join date: 12 Jul 2009
Posts: 11
|
09-06-2009 12:45
So I have to change it to collision_start to make it work better?
|