Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Consistant Push

Archanox Underthorn
Registered User
Join date: 20 May 2003
Posts: 168
02-19-2006 13:31
Heya, I haven't worked much with llPushObject before and I ran into a lil problem, wondering if someone had a solution. I'm looking for a push that does a consistant amount, reguardless of the mass of the pusher or the target, or the distance. So far I have it setup so it takes the energy falloff into account, and is then multiplied by the target's mass, so the same push will happen on any size target prim reguardless of distance:

From: someone

float basepow = 45;
basepow *= llGetObjectMass(avkey);

float power = basepow*(1/(1/llPow(llVecDist(llGetPos(), avloc), 3)));'


The one thing I haven't accounted for here is the pusher's mass. I tried dividing basepow by llGetMass() but that doesn't seem to be consistant. Ideas? Solutions?
_____________________
Archatek

Home to some of the highest quality katanas and other blades available in SL. Co-creator of the Samurai Island Combat System, one of the best melee combat systems available, come check it out!

___________________
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
02-19-2006 16:40
I'm pretty sure, although I can't find it now, that the mass of the pushing object is pretty much irrelevant. It will make a limit to the max push (this mythical 'energy' that the prim has seems to be based on pushing object's mass).

I use force number * llDetectedMass() * distance^3 to get my consistent pushes. This formula has pushed me, a standard prim and a 10m cube basically the same distance away as near as I could determine when it hit all of us at the same time.

Slightly unrelated, I noticed your kenjutsu scoring, when do you run the bouts, and how? Maybe PMing me is the right way to go though, if that's OK? :)
Seifert Surface
Mathematician
Join date: 14 Jun 2005
Posts: 912
02-19-2006 16:47
From: Eloise Pasteur
I use force number * llDetectedMass() * distance^3 to get my consistent pushes.

Distance measured from where? If one is standing in the middle of a large phantom prim that is pushing you then distance from the center is 0, but then you'd be pushing with force 0, which can't be right.
_____________________
-Seifert Surface
2G!tGLf 2nLt9cG
Archanox Underthorn
Registered User
Join date: 20 May 2003
Posts: 168
02-20-2006 00:10
Ah ok, after a bunch of trial and error I got it. To factor out the pusher's mass, you have to divide the push power by (llGetMass() / 2). Not sure why that is, just the way it factors in the pusher's mass I guess.

Edit: Oh as for the energy limit thing, I'm not doing sim-clearing pushes, just a light hit directed at an avatar. So I don't think I'm gonna hit that limit.
_____________________
Archatek

Home to some of the highest quality katanas and other blades available in SL. Co-creator of the Samurai Island Combat System, one of the best melee combat systems available, come check it out!

___________________
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
02-20-2006 01:36
Arachnox:

I had assumed you didn't figure on throwing people out of sim, but I'm never quite clear just how much energy a prim has. The divide by half mass sounds weird, but there you go, lol.

Seifert:

I work out distance from llGetPos and llDetectedPos - you can be within a sphere and as long as your detected position isn't precisely at the llGetPos position you get the push. To push you to the centre of a sphere I'd use a similar formula, but a different push direction. It might not be perfect for every application, but so far I've always had a non-zero distance in every test and for my application I had a bomb which was solid, so hopefully (unless the sim is playing up) little risk of interpenetration.
Seifert Surface
Mathematician
Join date: 14 Jun 2005
Posts: 912
02-20-2006 02:10
From: Eloise Pasteur
Arachnox:

I had assumed you didn't figure on throwing people out of sim, but I'm never quite clear just how much energy a prim has. The divide by half mass sounds weird, but there you go, lol.
Sounds weird to me too, but if it works...
Energy: I work with pretty big phantom prims, pushing when the avatar is supposed to be inside. A couple of reasonable pushes in quick succession can start to hit energy constraints. I read somewhere that smaller prims recharge faster, or maybe larger prims have more oomph or something, dunno.

From: Eloise Pasteur
Seifert:

I work out distance from llGetPos and llDetectedPos - you can be within a sphere and as long as your detected position isn't precisely at the llGetPos position you get the push. To push you to the centre of a sphere I'd use a similar formula, but a different push direction. It might not be perfect for every application, but so far I've always had a non-zero distance in every test and for my application I had a bomb which was solid, so hopefully (unless the sim is playing up) little risk of interpenetration.
Heh, and I've been working assuming interpenetration. My guess is that it falls off as r^3 once outside the bounding box of the prim, and inside there's not much if any effect of the exact position of the pushee. Having said that, I've had some weird fall off stuff happen pushing from inside a hollow prim (i.e. the avatar is within the bounding box but not inside the prim itself, which is not phantom).
_____________________
-Seifert Surface
2G!tGLf 2nLt9cG
Lex Neva
wears dorky glasses
Join date: 27 Nov 2004
Posts: 1,361
02-20-2006 09:32
From: Seifert Surface
Distance measured from where? If one is standing in the middle of a large phantom prim that is pushing you then distance from the center is 0, but then you'd be pushing with force 0, which can't be right.


Good point. From what I can tell, llApplyImpulse just divides the push strength by the cube of the distance between the objects... if the distance is zero, they wouldn't be dividing by zero, or we'd know about it really quickly ;) For that matter, if the distance is less than 1.0, this would effectively increase the push strength... Huh. How the heck does gravity work for distances under "1"?
Lex Neva
wears dorky glasses
Join date: 27 Nov 2004
Posts: 1,361
02-20-2006 09:45
From: Archanox Underthorn
Ah ok, after a bunch of trial and error I got it. To factor out the pusher's mass, you have to divide the push power by (llGetMass() / 2). Not sure why that is, just the way it factors in the pusher's mass I guess.


No, that doesn't sound right, I don't think...

Here's what's going on, as near as I can tell. Physics tells us that Force = Mass * Acceleration, but that doesn't mean much if you don't know for how long the force is applied. With llPushObject, we're not applying a force, we're applying an impulse, which is a force times a time, essentially. Impulse = mass * velocity. So what you're doing here is to add some velocity to the target's existing velocity. You'll need to decide on how fast you want the target to go, and multiply that by the mass of the target to get the impulse.

Then you have to figure in the somewhat-blackbox cubic falloff that llApplyImpulse conveniently does for us without really telling us exactly what it's doing. Generally, multiplying by the cube of the distance to the target works, but Seifert brings up a good point about what happens when the distance is less than 1...

One common trick is the "set velocity" method. You do something like this:

llPushObject(target, target_mass * llPow(distance_to_target,3) * (new_velocity - target_current_velocity));

What I mean by that is that you simultaneously exactly cancel the object's velocity and then give it a new velocity. I've seen this work to good effect.
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
02-20-2006 10:43
From: Lex Neva
Good point. From what I can tell, llApplyImpulse just divides the push strength by the cube of the distance between the objects... if the distance is zero, they wouldn't be dividing by zero, or we'd know about it really quickly ;) For that matter, if the distance is less than 1.0, this would effectively increase the push strength... Huh. How the heck does gravity work for distances under "1"?


If you had a RL point source of signigificant gravity - lots of ifs there really - it works as you'd expect.

The closer you get to something (no matter how massive) the harder gravity sucks, until you hit it's surface and you get upthrust to match the pull of gravity (which we like to call weight).

If you're close to earth it pulls quite hard. If you're further away from the centre it pulls less hard. I can't remember the differences exactly, but a pendulum clock that runs right in death valley runs slow on top of Everest. That's not quite the experiment they actually did, but something similar.
Seifert Surface
Mathematician
Join date: 14 Jun 2005
Posts: 912
02-20-2006 13:01
From: Lex Neva
Huh. How the heck does gravity work for distances under "1"?
It's called a black hole. The force does go to infinity (well, it all goes non-Newtonian long before then so who knows). For something like the Earth you can't get closer than the surface of it, and if you start digging down into it then the stuff above you is pulling you away from the center so it no longer acts like a point mass with the mass of the entire Earth. IIRC with a spherical uniform density planet it turns out that the force you feel is as if any stuff at a higher altitude than you doesn't exist. So if you're inside a spherical shell of matter the net force on you is zero.

As for our stuff, someone should ask a Linden what the real deal is...
_____________________
-Seifert Surface
2G!tGLf 2nLt9cG
Argent Stonecutter
Emergency Mustelid
Join date: 20 Sep 2005
Posts: 20,263
02-20-2006 14:52
From: Lex Neva
For that matter, if the distance is less than 1.0, this would effectively increase the push strength... Huh. How the heck does gravity work for distances under "1"?
Working with small objects, the r^3 relation for pushes continues below 1m. For large phantom objects? I haven't tried that.
Archanox Underthorn
Registered User
Join date: 20 May 2003
Posts: 168
02-20-2006 17:54
Well I went back in and tested things a bit more just to be sure. Pushing a 5x5 block with a .5x.5 and vice versa along with a few other shapes. As far as I can tell, this works (to a reasonable extent, theres a slight amount of difference between two pushes with everything setup exactly the same). Here's the code, try it out yourself.

CODE

string objname = "testobj";

default
{
sensor(integer num)
{
float basepow = 25;
basepow *= llGetObjectMass(llDetectedKey(0));
basepow /= llGetMass() / 2;

float power = basepow * llPow(llVecDist(llGetPos(), llDetectedPos(0)), 3);
llPushObject(llDetectedKey(0), <0,0,power>, ZERO_VECTOR, FALSE);
}

touch_start(integer total_number)
{
llSensor(objname, "", AGENT|ACTIVE|PASSIVE, 10, TWO_PI);
}
}

I understand your point about if the distance is zero, and I'm assuming there's prolly some kind of protection that adds a small offset to the distance if it's zero.(black holes would be fun tho ^^) Just my take on it.

Edit: Just as a sidenote, when pushing the 5x5 object with the .5x.5 object it only works until approx 9.7m away, after that the pushing object lacks the energy.
_____________________
Archatek

Home to some of the highest quality katanas and other blades available in SL. Co-creator of the Samurai Island Combat System, one of the best melee combat systems available, come check it out!

___________________
Lex Neva
wears dorky glasses
Join date: 27 Nov 2004
Posts: 1,361
02-21-2006 09:42
From: Seifert Surface
It's called a black hole. The force does go to infinity (well, it all goes non-Newtonian long before then so who knows). For something like the Earth you can't get closer than the surface of it, and if you start digging down into it then the stuff above you is pulling you away from the center so it no longer acts like a point mass with the mass of the entire Earth. IIRC with a spherical uniform density planet it turns out that the force you feel is as if any stuff at a higher altitude than you doesn't exist. So if you're inside a spherical shell of matter the net force on you is zero.

As for our stuff, someone should ask a Linden what the real deal is...


Ah, right, of course. Thanks for clearing that up. Yeah... I think this might be a good question for the Hotline.
Lex Neva
wears dorky glasses
Join date: 27 Nov 2004
Posts: 1,361
02-21-2006 09:46
From: Archanox Underthorn
Well I went back in and tested things a bit more just to be sure. Pushing a 5x5 block with a .5x.5 and vice versa along with a few other shapes. As far as I can tell, this works (to a reasonable extent, theres a slight amount of difference between two pushes with everything setup exactly the same). Here's the code, try it out yourself.

CODE

string objname = "testobj";

default
{
sensor(integer num)
{
float basepow = 25;
basepow *= llGetObjectMass(llDetectedKey(0));
basepow /= llGetMass() / 2;

float power = basepow * llPow(llVecDist(llGetPos(), llDetectedPos(0)), 3);
llPushObject(llDetectedKey(0), <0,0,power>, ZERO_VECTOR, FALSE);
}

touch_start(integer total_number)
{
llSensor(objname, "", AGENT|ACTIVE|PASSIVE, 10, TWO_PI);
}
}



I'm still wondering about that factor of two. I have seen a factor of two become necessary in a similar but slightly different context... but here, I wonder if it's just factoring into the basepow, and lowering the resultant imparted velocity to 12.5? If not, then maybe it has to do with an integral of impulse over time, which would end up with a 1/2 factor in there, ala Kinetic Energy = 1/2 * m * v^2
Ordinal Malaprop
really very ordinary
Join date: 9 Sep 2005
Posts: 4,607
02-21-2006 09:58
Can we get this push formula confirmed by people, and stick it in the wiki?

In fact, why won't LL just tell us this stuff directly, and put it in the documentation? For that matter, why not tell us how energy works, too?

edit: er, has anyone asked them?