Jump to content

Movable Elevator Dilemma


Flick1
 Share

You are about to reply to a thread that has been inactive for 4762 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

I want to be able to have a platform moving up and down that is linked to an object that stays still.

Basically making one object that has a moving part...

My platform can move up and down perfect, it's a simple script that more or less says, move up 2 metres, move down to metres, alternatively as you touch it.

HOWEVER, when I Link this platform to an object, the object moves in the same way the platform does...

I think I understand that the "platform is the parent" and the "object is the child", and I'd like the child to stay put while the parent does it's thing, or perhaps even if I make the child the platform which can move, and the parent the object which stays put.

Please help me I'm sure it's a simple scripting solution.

 

Thanks

 

Link to comment
Share on other sites

You'll keep it simple for yourself if you make the root (parent) the non-moving part, this will be the more stable solution especially if you want the elevator moving unattended for long periods without accumulating prim drift.

Link to comment
Share on other sites

I experimented with making the non-moving part the root (parent), and the moving part the child - but the root (parent) still inherited the childs script and both objects elevated...

I actually already have a prim attached to this object as a door which could be causing problems...

I'm not actually making this but it could be well described as:

- an elevator shaft with a door linked at the bottom linked to an elevator box which moves up and down inside it,. (essentially making a entire elevator system in one package, so that it can be rezed and moved wherever)

This is not actually what I'm making but has similiar characteristics of this... lol

I hope this makes sense.

 

Link to comment
Share on other sites

If the moving plattform is the child and is to move along the parents z axis, the script would look something like this (with the script in the child only:

 

integer up;vector pos;default {	state_entry() {		pos = llGetPos();	}    touch_end(integer num_detected) {    	if (up) {    		llSetPos(pos + <0,0,2>);    	} else {    		llSetPos(pos);    	}    	up = !up;    }}

 A root doesn't inherit a childs scripts - mae sure you are actually adding the script to the child. You can only select a child in a linkset if you mark "Edit Linked Parts" in the little Edit window

 

Link to comment
Share on other sites

if you put your script in the part you want to move then you can move it around something like this:

integer x;
default
{
    state_entry()
    {
        
    }

    touch_start(integer total_number)
    {if (x == 0)
        {vector v = llGetLocalPos();
        llSetPos (<v.x , v.y, (v.z + 1)>);
        x = 1;
        return;
        }
        if (x == 1)
        {vector v = llGetLocalPos();
        llSetPos (<v.x , v.y, (v.z - 1)>);
        x=0;
        return;
        }
        
    }
    
    
    }

not the most efficient surely just something i quickly hacked out to move a piece 1 up and 1 down alternately on the z axis when touched. hope that is some help to you :matte-motes-sunglasses-1:

Link to comment
Share on other sites

This worked perfectly dude, now I need to be able to do one more thing...

 

The platform is moving up and down inside the box, but I want to be able to have a pos ball or just be able to sit on the platform in a certain animation that I have, and when the platform goes up so will the avi who is seated on the platform

 

Link to comment
Share on other sites

You'd need the following steps (there are different ways, but the basic ingredients are the same ones. This one is assuming that the plattform is what you're sitting on):

Of course the are bells and whistles you can add, e.g. by unsitting the ava as soon as the elevator has reached its target, but this should give you an idea of how to design your script.

Link to comment
Share on other sites


Darkie Minotaur wrote:

You'd need the following steps (there are different ways, but the basic ingredients are the same ones. This one is assuming that the plattform is what you're sitting on):

Is there a trick to this?  I was working on a new project just the other day, and when I put a sit target on a child prim that was moved in a link set with llSetPos, my avatar did not move with the child prim.   

Link to comment
Share on other sites

I looked at Strife's UpdateSitTarget again, and had a play and, rather to my surprise, managed to come up with this -- called from the root prim -- which seems to do it.  

I'm not competely sure I've done it right, but I tried rotating the "platform" prim on which I sit round on its z axis and ended up in the right direction, which was what worried me a bit.

 

ETA -- it needs resetting before you first use it, I have realised, in order to set prim_pos.   It would be nice to reset it when the links change, but that's going to mess stuff up when the avatar gets off.  I'm sure there's a simple solution, but if you use it, be aware that the script needs resetting before first use.

 

vector sit_target =<0.0,0.0,0.5>;//same as the sit target set in the platform primrotation sit_rot = ZERO_ROTATION;//same as the sit target set in the platform priminteger platform;integer toggle;key av;vector offset;vector size;vector prim_pos;find_prims(){	integer max=llGetNumberOfPrims()+1;	while(max--){		if(llToLower((string)llGetLinkPrimitiveParams(max,[PRIM_NAME]))=="platform"){			platform = max;		}	}}default{	state_entry()	{		find_prims();		list prim_details=llGetLinkPrimitiveParams(platform,[PRIM_POSITION]);		prim_pos =llList2Vector(prim_details,0)-llGetRootPosition()/llGetRootRotation();	}	changed(integer change){		if(change& CHANGED_LINK){			find_prims();		}	}	touch_start(integer total_number)	{		list av_details=[];		vector av_offset;		vector sit_offset = sit_target;		size = llGetAgentSize(llGetLinkKey(llGetNumberOfPrims()));		if(size!=ZERO_VECTOR){			av=llGetLinkKey(llGetNumberOfPrims());			av_details= llGetLinkPrimitiveParams(llGetNumberOfPrims(),[PRIM_ROT_LOCAL]);		}		llOwnerSay(llList2String(av_details,0));		toggle=!toggle;		if(toggle){			offset =<prim_pos.x,prim_pos.y,5.0>;		}		else{			offset =prim_pos;		}		if(av_details!=[]){			sit_offset.z+=0.4;			vector v = llList2Vector(av_details,0)-llGetRootPosition()/llGetRootRotation();			llOwnerSay((string)v);			if(toggle){				av_offset =<prim_pos.x,prim_pos.y,5.0>;			}			else{				av_offset=prim_pos;			}			av_offset +=sit_offset;			av_offset =av_offset+(llRot2Up(sit_rot) * size.z * 0.02638) * llList2Rot(av_details,0);			llSetLinkPrimitiveParamsFast(llGetNumberOfPrims(),[PRIM_POSITION,av_offset*llGetRootRotation()]);		}		llSetLinkPrimitiveParamsFast(platform,[PRIM_POSITION,offset*llGetRootRotation()]);	}}

 

 

Link to comment
Share on other sites

 


Kenbro Utu wrote:

So you have to update the sit target as the child prim moves.  That could qualify as a pseudo-trick.  :smileywink:

 

Well, sort of.   Except you aren't updating the sit target at all (that doesn't have any effect while the avatar is seated, you see).   The UpdateSitTarget function by Strife Onizuka and Escort DeFarge (which poseball-free animation systems like nPose and Perfect Sitter use) uses llSetLinkPrimitiveParams to move the avatar about in the way we've all wanted to when we've said, "If only you could update the sit target when someone's sitting". 

I took their calculations and method and played round with them a bit to get the platform child prim and the avatar sitting on it to move together to the correct end positions without drifting too far apart in transit.

 

 

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 4762 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...