Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Info on llPushObject ?

Rick Rutledge
Second Lifer
Join date: 9 Nov 2004
Posts: 27
11-22-2004 08:43
I'm trying to use this in a script, and I'm not sure what the vectors are doing, or what some good values would be to nudge an AV back by about 2 meters. Any advice on how the force vectors work would be appreciated.

Rick
Cross Lament
Loose-brained Vixen
Join date: 20 Mar 2004
Posts: 1,115
11-22-2004 13:29
I Rick!

I assume you've already read the wiki entry for llPushObject?

impulse is a vector value containing the impulse to be applied to the target object. Impulse is measured in units of kg m/s, in this case expressed as a vector to give it a direction as well as magnitude. Probably the easiest way to do this is to generate a unit vector to represent the direction you want to push, then multiply that by the mass of the target, and then desired velocity. To get a unit vector representing the direction away from the scripted object, towards the target (ie. you want to push the target away from the scripted object), you would use:

llVecNorm( targetpos - mypos ) ;, where targetpos is a vector containing the region-coordinates of the target (usually obtained with llDetectedPos()), and mypos is a vector containing the region-coordinates of the scripted object (usually obtained via llGetPos()).

angular_impulse is only used if you want to give a spin to the target.

local is a true/false value that determines if the impulse applied should be relative to the target's rotation (true), or to the region-coordinate axes (false).

Did that make any sense at all? I'm not sure it did. :D
_____________________
- Making everyone's day just a little more surreal -

Teeple Linden: "OK, where did the tentacled thing go while I was playing with my face?"
Rick Rutledge
Second Lifer
Join date: 9 Nov 2004
Posts: 27
11-22-2004 15:45
From: Cross Lament
I Rick!

I assume you've already read the wiki entry for llPushObject?


Yes, I read it, but I'm not clever enough to know what it means :)

A vector is composed of three numbers, right? <0.0, 0.0, 0.0>

But what do the numbers mean? What part is the velocity? Is it three Delta Vee numbers, like velocity on the x axis, y axis, and z axis? Right now I am using

<-30.0, 0.0, 160.0>

and setting local to TRUE, which tends to push the avatar a little backward and a little upward, as desired. It's for a diving board script that I'm working on, trying to improve on the trampoline bouncing scripts. Would it be better to calculate the mass of the avatar and adjust the numbers for each one that touches the "pushing" object?
Cross Lament
Loose-brained Vixen
Join date: 20 Mar 2004
Posts: 1,115
11-22-2004 21:16
That's more or less correct, yes. The three values of a velocity vector represent the x, y, and z axis components of the total velocity. If you want to do the math, it's

v^2 = x^2 + y^2 + z^2

The same applies to impulse vectors, each value is the componet of the total impulse along that particular axis. :)

I guess you would want to have local set to TRUE for something like a diving board, so they can steer where they're going. :eek: Unfortunately, there's no way to directly detect the mass of an avatar through detected() events. You could probably kludge something by assuming that a 2m tall avatar weighs say, 75kg. Then you could use a code snippet like this in the detected event to fake the mass. :)

CODE

// I converted the vector you used into a unit vector
// You could also get this value by: vector direction = llVecNorm( -30, 0, 160 ) ;
vector direction = < -0.184, 0, 0.982 > ;

// This is the desired velocity in m/s
float speed = 5.0 ;

// The key of the target
key id = llDetectedKey( 0 ) ;

// Fudge the mass by finding the ratio of the target's height to the 'average' height
// then multiplying that by the 'average' mass; obviously, the 'average mass' value
// can stand some tweaking
vector targetsize = llGetAgentSize( id ) ;
float mass = targetsize.z / 2.0 * 75.0 ;

llPushObject( id, direction * mass * speed, ZERO_VECTOR, TRUE ) ;
_____________________
- Making everyone's day just a little more surreal -

Teeple Linden: "OK, where did the tentacled thing go while I was playing with my face?"
Rick Rutledge
Second Lifer
Join date: 9 Nov 2004
Posts: 27
11-23-2004 11:50
Hey thanks! I'm beginning to understand it a little better. I think maybe I WON'T set local to TRUE, so I can force the AV to dive towards the pool, instead of the cement. :)

I plan to put in a random factor - sometimes the Av will make a great dive, sometimes a bellywhopper.

So far, my backflip dive works good, but with your info, I'm going to be able to fine-tune it and get it just right!
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
11-25-2004 05:42
use the avatar bounding box to figure the mass.
_____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river.
- Cyril Connolly

Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence.
- James Nachtwey