Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Strange Effect when Avatar Stands

Brett Bjornson
Registered User
Join date: 8 Nov 2005
Posts: 25
02-21-2007 16:10
The following script is working, except for two items. First, when the avatar stands, he gets "stuck" in the object and runs in place like crazy. I need to move him away from the object when he stands. I've tried this with llPushObject, but it doesn't do anything.

The second problem is the llRezObject command. What I want is to rez an object in mid-air that immediately falls directly down to the ground. What I have now is an object that rezzes and bounces up and away.

All help is appreciated. Here's the script:

key agent = NULL_KEY;
integer i; //A simple counter.


default
{
state_entry()
{
llSetSitText("Chop!";);//Set the Pie Menu text.

//Set the sitting position and rotation.
vector sittingPosition = <0.0,0.85,-0.25>;
vector sittingRotation = <90, 180, 90>;

llSitTarget(ZERO_VECTOR,ZERO_ROTATION); //Clear the sit target.
llSitTarget(sittingPosition,llEuler2Rot(sittingRotation * DEG_TO_RAD));// Needed for llAvatarOnSitTarget to work
llSetCameraEyeOffset(<4, 4, 3>;); //Position the camera.
llSetCameraAtOffset(<2, 0, 1>;);
}

changed(integer change)
{
if(change & CHANGED_LINK) //Is someone sitting?
{
key current_agent = llAvatarOnSitTarget();
if(current_agent != NULL_KEY) //Yes, someone is sitting.
{
llRequestPermissions(current_agent, PERMISSION_TRIGGER_ANIMATION); //This does NOT spawn a dialog, as it's used in conjunction with run_time_permissions! You still need to include it, however.
}
else //No one is sitting.
{
llSetStatus(STATUS_PHANTOM, TRUE);
llPushObject(current_agent, (<10, 0, 7> * llGetRot()), ZERO_VECTOR, FALSE);
llSetStatus(STATUS_PHANTOM, FALSE);
llStopAnimation("HeadChop";);
agent = NULL_KEY;
//reset the script to release permissions
llResetScript();
}
}
}

run_time_permissions(integer perm)
{
agent = llAvatarOnSitTarget();
if(perm & PERMISSION_TRIGGER_ANIMATION)
{
llStopAnimation("sit";); //Stop the default sit animation - it looks stupid here.
llStartAnimation("LayDown";);
llSleep(1); //Pause for effect.
llPlaySound("door_open", 1);
llMessageLinked(LINK_SET,0,"t1",NULL_KEY); //Send a message to other scripts in other linked child prims.
llStopAnimation("LayDown";);

llStartAnimation("HeadChop";);
rotation rot = llGetRot();
vector aim = llRot2Fwd(rot);

llRezObject("Smiley", llGetPos() + <0, 1.5, 0>, <4.0,4.0,4.0> *llGetRot(), llGetRot(), 1);
llPlaySound("diescream", 1);
llMessageLinked(LINK_SET,0,"reset",NULL_KEY);
}
}

on_rez(integer start_param)
{
llResetScript();
}

}
Pale Spectre
Registered User
Join date: 2 Sep 2005
Posts: 586
02-21-2007 16:43
On the first point I think you need to go back and look at Newgate's script again /54/19/167279/1.html

From: Newgate Ludd
Your code needs to remember who the agent was and then push them when they are no longer sitting.
current_agent will be NULL for the else in your script as you have it now.
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
02-22-2007 00:25
From: Pale Spectre
On the first point I think you need to go back and look at Newgate's script again /54/19/167279/1.html


Quote:
Originally Posted by Newgate Ludd
Your code needs to remember who the agent was and then push them when they are no longer sitting.

current_agent will be NULL for the else in your script as you have it now.


We may be flagellating a deceased equine here Pale, Thats exactly what I pointed out last time.
Brett Bjornson
Registered User
Join date: 8 Nov 2005
Posts: 25
I tried that
02-22-2007 05:47
From: Newgate Ludd
We may be flagellating a deceased equine here Pale, Thats exactly what I pointed out last time.


I tried that script portion verbatim. It didn't work, so I started monkeying with it. Just to be sure, I put the script portion that Newgate Ludd provided back in, and tried it again. Same thing.

I made a movie of this:

http://www.personal.psu.edu/bxb11/temp/Stuck.mov

so you can see what's happening. I'm not a dead horse, just a confused one! :)

Here is the entire script again, with the provide code as is:

key agent = NULL_KEY;


default
{
state_entry()
{
llSetSitText("Chop!";);//Set the Pie Menu text.

//Set the sitting position and rotation.
vector sittingPosition = <0.0,0.85,-0.25>;
vector sittingRotation = <90, 180, 90>;

llSitTarget(ZERO_VECTOR,ZERO_ROTATION); //Clear the sit target.
llSitTarget(sittingPosition,llEuler2Rot(sittingRotation * DEG_TO_RAD));// Needed for llAvatarOnSitTarget to work
llSetCameraEyeOffset(<4, 4, 3>;); //Position the camera.
llSetCameraAtOffset(<2, 0, 1>;);
}

changed(integer change)
{
if(change & CHANGED_LINK) //Is someone sitting?
{
key current_agent = llAvatarOnSitTarget();
if(current_agent != NULL_KEY) //Yes, someone is sitting.
{
agent = current_agent;
llRequestPermissions(agent, PERMISSION_TRIGGER_ANIMATION);
}
else //No one is sitting.
{
llStopAnimation("HeadChop";);
llPushObject(agent, 15.0 * llRot2Left(llGetRot()), <10.0,10.0,10.0>, FALSE); //Move the avatar off the object.
agent = NULL_KEY;
}
}
}

run_time_permissions(integer perm)
{
agent = llAvatarOnSitTarget();
if(perm & PERMISSION_TRIGGER_ANIMATION)
{
llStopAnimation("sit";); //Stop the default sit animation - it looks stupid here.
llStartAnimation("LayDown";);
llSleep(1); //Pause for effect.
llPlaySound("door_open", 1);
llMessageLinked(LINK_SET,0,"t1",NULL_KEY); //Send a message to other scripts in other linked child prims.
llStopAnimation("LayDown";);

llStartAnimation("HeadChop";);
rotation rot = llGetRot();
vector aim = llRot2Fwd(rot);

llRezObject("Smiley", llGetPos() + <0, 1.5, 0>, <4.0,4.0,4.0> *llGetRot(), llGetRot(), 1);
llPlaySound("diescream", 1);
llMessageLinked(LINK_SET,0,"reset",NULL_KEY);
}
}

on_rez(integer start_param)
{
llResetScript();
}

}
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
02-22-2007 06:34
Well you can read :) Always a good start to getting rid of confusion.

My code was untetsed but its pretty much standard code.

First lets check the obvious, please bare with me if you've already done so.

1) Push is enabled ?
2) Now a slightly more subtle query, whats the relative mass of the pushing object compared to the Avatar? Try upping the impulse numbers by a few 1000 just to check.
Valradica Vanek
Registered User
Join date: 1 Aug 2006
Posts: 78
rez a falling object;
02-22-2007 12:04
To make your "head roll" so to speak, you have to set the parameters in the object that will be rezzed. When it is rezzed, you have to set he boyancy to 0.0 (so it will fall) you have to turn the physics on. Here is a snippet of code that is an example from a projectile that I am using in a recent project.

this goes in the main script somewhere"
CODE

llRezObject("HappyHead", vector pos, vector vel, rotation rot, 23);


this goes in the rezzable object:

CODE

state_entry() {
llCollisionSound("", 0.0); //This diables the collision sound and sprites
}

on_rez (integer startparam) {
if (startparam == 23) {
llSetPrimitiveParams([PRIM_PHYSICS, TRUE]);
llSetBuoyancy(0.0);
}
}


use the start parameter given by the llRezObject (integer startparam) command so that you can rez the object and work on it without the parameters being set. when you rez the object from inventory, the physics will be set to true and the bouyancy will be 0.0 ( the thing will fall and roll down hill)

If you want to give it a slight kick in certain direction, that kick goes in as velocity in the llRezObject command. Your position and rotation are situation dependent of course.

If you want it to fall slower, give it a little bouyancy.
Brett Bjornson
Registered User
Join date: 8 Nov 2005
Posts: 25
Thanks!
02-22-2007 17:16
All this helped a lot. Increasing the push force did the trick. It seems like there is a threshold, once you hit it then the push works. Thanks again.

Now I have another problem (grin). The rezzed sphere was working just fine, appearing where I wanted it and dropping correctly. Then I rotated the guillotine, and the rezzed sphere is still appearing in the old position. So I obviously have some more work to do there.

Also, it seems like sometimes I'll make a change to the script, and the changes don't seem to take hold for a period of time. In other words, the change might not show up for several minutes. Am I crazy? Should I take the objects I'm working on a re-rez them periodically? Should I always reset a script after I save and change it?
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
02-22-2007 22:22
From: Brett Bjornson
All this helped a lot. Increasing the push force did the trick. It seems like there is a threshold, once you hit it then the push works. Thanks again.

Now I have another problem (grin). The rezzed sphere was working just fine, appearing where I wanted it and dropping correctly. Then I rotated the guillotine, and the rezzed sphere is still appearing in the old position. So I obviously have some more work to do there.

Also, it seems like sometimes I'll make a change to the script, and the changes don't seem to take hold for a period of time. In other words, the change might not show up for several minutes. Am I crazy? Should I take the objects I'm working on a re-rez them periodically? Should I always reset a script after I save and change it?



Yopu need to take into account the rotation so multiply the rezzed object position by the current object rotation.

Lag will do that, If the dataserver starts playing silly buggers you can quite happily watch your object bouncing all around the sim as it slowly catches up with you.
Brett Bjornson
Registered User
Join date: 8 Nov 2005
Posts: 25
Still stupid
02-23-2007 09:34
OK, I tried that via

vector pos = llGetPos() * llGetRot();

and then rezzed the object via

llRezObject("Smiley", pos, aim, ZERO_ROTATION, 1);

but it doesn't work, so I'm obviously doing something wrong.

The objects position is <203.04555, 45.58462, 22.46631>, multiplying the rotation returns <-195.11534, 72.35647, 22.46632>

The rotation of the root prim of the object is

X - 0
y - 0
z - 147

if that helps.
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
02-23-2007 10:29
Ok, my fault I wasnt explicit in what I was saying.
If youa re rezzing at the same location i.e. at llGetPos() then you dont multiply by the rotation. If you are rezzing at an offset from that point, i.e. llGetPos() + <0, 0, 2 >; then multiply the offset by the rotation.

also where you have ZERO_ROTATION, use llGetRot().

CODE

vector offset = <0,1,1>; // example only!
rotation rot = llGetRot();
vector pos = llGetPos() + (offset * rot);
llRezObject("HappyHead", pos, <0,0,0>, rot, 0);
Brett Bjornson
Registered User
Join date: 8 Nov 2005
Posts: 25
It worked!
02-23-2007 13:38
Thanks so much for all your help! Could not have done it without you!