Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Floating objects

Haravikk Mistral
Registered User
Join date: 8 Oct 2005
Posts: 2,482
11-24-2005 06:35
Is it possible to make an item that bounces off of phantom objects? The reason I'm asking is that I've placed a beach ball in part of my building where there are 'artificial' pools, ie since I can't use the actual water I've simply placed a prim that LOOKS like water and is phantom so you can wade into it.

Anyway, the beach-ball simply falls through it which isn't really what I want. If it isn't possible to do true collisions, then another alternative is to do it based purely on height, this would actually be more convenient as I wouldn't want the ball leaving that floor (in case someone manages to get it out the door and into the stairwell).
Senuka Harbinger
A-Life, one bit at a time
Join date: 24 Oct 2005
Posts: 491
11-24-2005 08:47
From: Haravikk Mistral
Is it possible to make an item that bounces off of phantom objects? The reason I'm asking is that I've placed a beach ball in part of my building where there are 'artificial' pools, ie since I can't use the actual water I've simply placed a prim that LOOKS like water and is phantom so you can wade into it.

Anyway, the beach-ball simply falls through it which isn't really what I want. If it isn't possible to do true collisions, then another alternative is to do it based purely on height, this would actually be more convenient as I wouldn't want the ball leaving that floor (in case someone manages to get it out the door and into the stairwell).



you can set up is a ground repel script with the height set at the height of the water. there may be more elaborate ways of achieving this through sensors, but I think this would be easiest.
Argent Stonecutter
Emergency Mustelid
Join date: 20 Sep 2005
Posts: 20,263
11-25-2005 07:40
From: Haravikk Mistral
Is it possible to make an item that bounces off of phantom objects?
llVolumeDetect on the phantom object, and have it either llPushObject the ball to make it bounce, or llSay() a message to the script in the ball to have it llApplyImpulse to get the same result. Using llPushObject should let you make water that bounced any physical object... not just the ball.
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
11-27-2005 05:06
And if you do Argent's one remember to unset your prim as phantom by other means - llVolumeDetect() does it for you, setting it phantom other ways seems to turn the llVolumeDetect off.
Haravikk Mistral
Registered User
Join date: 8 Oct 2005
Posts: 2,482
12-27-2005 12:20
From: Argent Stonecutter
llVolumeDetect on the phantom object, and have it either llPushObject the ball to make it bounce, or llSay() a message to the script in the ball to have it llApplyImpulse to get the same result. Using llPushObject should let you make water that bounced any physical object... not just the ball.


Hey, sorry to bump this thread after so long. But I'm not sure what I should be doing with my llPushObject, could you give an example? I will likely have it based on the name of the object.
The idea would be to have the force applied to the ball simply be the exact opposite of it's downwards component, what's the easiest way to do this?
This would stop the ball as soon as it hits the water, but still allow it to run out of energy normally in the X or Y directions.

I'm trying this, but it does not work:
CODE
if (llDetectedName(x) == "Beach Ball") {
vector vel = llDetectedVel(x);
llPushObject(llDetectedKey(x),
<0,0,-(vel.z * llGetObjectMass(llDetectedKey(0)))>,ZERO_VECTOR,FALSE);
}
Beatfox Xevious
is THOUSANDS OF PEOPLE
Join date: 1 Jun 2004
Posts: 879
12-27-2005 13:48
I'm not sure whether this is the cause of your problems, but did you mean for that "llDetectedKey(0)" on the last line to instead be "llDetectedKey(x)"?
_____________________
My Beatworks: Zephyr Chimes wind chimes, the KanaMaster Japanese kana tutor, and the FREE Invisibility Prim Public. Look for them at the Luskwood General Store in Lusk (144, 165).

"You have been frozen. You cannot move or chat. A pony will contact you via instant message (IM)."
- mysterious system message I received after making off with Pony Linden
Haravikk Mistral
Registered User
Join date: 8 Oct 2005
Posts: 2,482
12-27-2005 14:39
Hmm, I'm not sure that it will matter or not, it only applies this to the most recent collision which I think is collision zero. I could be wrong, but the only object colliding at the time is the beach-ball anyway so it shouldn't affect it.
Thanks for pointing it out, but it might only be a problem later =)
Beatfox Xevious
is THOUSANDS OF PEOPLE
Join date: 1 Jun 2004
Posts: 879
12-27-2005 16:11
From: Haravikk Mistral
I could be wrong, but the only object colliding at the time is the beach-ball anyway so it shouldn't affect it.

That would be true, if there were no other prims adjoining the water prim. I assume there are also prims forming the sides of the pool?
_____________________
My Beatworks: Zephyr Chimes wind chimes, the KanaMaster Japanese kana tutor, and the FREE Invisibility Prim Public. Look for them at the Luskwood General Store in Lusk (144, 165).

"You have been frozen. You cannot move or chat. A pony will contact you via instant message (IM)."
- mysterious system message I received after making off with Pony Linden
Haravikk Mistral
Registered User
Join date: 8 Oct 2005
Posts: 2,482
12-27-2005 16:34
Yeah but they don't come up in the collision event, I've checked that much, the only thing llDetectedName(0) returns is "Beach Ball", so I know that part works, but the ball still falls through :P

It's definitely the llPushObject() not working as I expected, or I'm messing up somewhere. I've also tried putting in big numbers to see it it made it any better, but there's no obvious effect on the beach ball colliding with the water.

I tried the llGroundRepel() function but it had erm...unpredictable results. Increasing the height it was to repel from (ie treat as ground as I understood it) made it fall DOWN, while decreasing it causes it to get stuck on the ceiling. Meanwhile choosing a mid-way point lost the ball entirely, no idea where it went, as it didn't even find it's way back again (it has an auto-return of five minutes if it goes out of the house).

Physics functions are frustratingly obscure =S
Ordinal Malaprop
really very ordinary
Join date: 9 Sep 2005
Posts: 4,607
12-28-2005 00:49
Remember that the force of llPushObject falls off with the cube of the distance between the two centres of mass. Try multiplying it by llPow(llVecMag(llDetectedPos(x) - llGetPos())), 3) ? I've not tried adjusting for this....
Beatfox Xevious
is THOUSANDS OF PEOPLE
Join date: 1 Jun 2004
Posts: 879
12-28-2005 11:12
From: Ordinal Malaprop
Remember that the force of llPushObject falls off with the cube of the distance between the two centres of mass. Try multiplying it by llPow(llVecMag(llDetectedPos(x) - llGetPos())), 3) ? I've not tried adjusting for this....

Heh. Once again, I neglected to factor that in. Thanks for the memory jog, Ordinal! :o

(What she said, Haravikk :) )
_____________________
My Beatworks: Zephyr Chimes wind chimes, the KanaMaster Japanese kana tutor, and the FREE Invisibility Prim Public. Look for them at the Luskwood General Store in Lusk (144, 165).

"You have been frozen. You cannot move or chat. A pony will contact you via instant message (IM)."
- mysterious system message I received after making off with Pony Linden
Haravikk Mistral
Registered User
Join date: 8 Oct 2005
Posts: 2,482
12-28-2005 15:47
Thanks for the continuing help! However this now seems much too powerful, but my tweaking isn't turning up much help. The code as I have it now is:

CODE
default {
collision_start(integer x) {
x = 0;
vector detPos = llDetectedPos(x);
vector myPos = llGetPos();
if (llDetectedName(x) == "Beach Ball") {
vector vel = llDetectedVel(x);
vector impulse = <0,0,llFabs(vel.z * llPow(llVecMag(detPos - myPos), 3)) * (llGetObjectMass(llDetectedKey(x)) * 0.75)>;
llOwnerSay((string)impulse);
llPushObject(llDetectedKey(x),impulse,ZERO_VECTOR,FALSE);
}
detPos.z = myPos.z;
llRezObject("Splash",detPos,ZERO_VECTOR,ZERO_ROTATION,1);
}
}


(the impulse lines is getting messy! Basically downwards velocity times the distance modifier times 3/4 of the mass. The absolute value is taken on the off-chance the ball passes through the water and is hitting it from underneath, so it will always be bounced upwards)

Anyway, this seems to be hitting it much too hard, my hopes would be for it to bounce off the water at the same speed that it hit the water at (or perhaps a little faster to stop it falling through), but my tweaking of it doesn't appear to be working too well.
Currently it will bounce hard up if it lands on the water at normal speed, and quite often gets stuck bouncing between the ceiling and water untill it smashes through the ceiling and disappears off world :(

Is there any way to force a physics body to simply stop without making it non-physical? I mean I'm tempted to go that route anyway, but it would be nice to be able to detect any physics body with a certain property (to represent that it floats on water) and have it simply stop moving it contacts with the water. I mean, most beachballs, regardless of the speed they hit water tend to just stop dead in it (unless they skim but we can ignore that for now).