Jump to content

Physics, pivots and gravity... (Scripting a swaying sign help.)


Minareth Irata
 Share

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

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

Recommended Posts

Hi all, I'm trying to Script a swaying sign, like you may see in some games. (Mostly in medieval themed games.) But Second Life physics are... Yeah... The first issue I run into is that physical Objects can't interpenetrate, like say you can't make chain links hooked on to each other unless they're really huge...

So what I did was make the post Phantom, and used a small Script to make the sign's Root Prim hold onto a position and limit it to rotate on one axis only.

sway_sign_example_d.png

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

The problem that occurs now is that the rotation isn't affected by gravity and the center of mass at all! When hitting the sign it keeps spinning around the pivot point and when it does come to a halt it isn't pulled down... I suppose there is no way to solve this? I know people advise to simulate the effect rather than using actual physics, but it's just that I want to see if I can make it work. I'm curious if it's possible at all with Physics and as little Scripting as possible.

Link to comment
Share on other sites

You might try a minimal script with a collision event that reacts to a collision by applying an opposing damping force with llApplyRotationalImpulse.  I haven't tried that, but that's what you would do in RL if you want to minimize rotational movement.

Link to comment
Share on other sites

Swinging sign_001.pngHi....  interesting problem :)...I took a stab at it....here is the script   and ill attach photo of sign object

//Swinging sign by Darleen Emerald 23 Oct 2014
vector start_pos = <215.036,208.059,46.611>;// note: just copy start_pos from edit object window
rotation start_rot;
integer started=FALSE;
default
{
    state_entry()
    {
        
        llSetStatus(STATUS_PHYSICS,FALSE);
        start_rot= llEuler2Rot(<0,90,0> * DEG_TO_RAD);
      
        
    }

    touch_start(integer total_number)
    {
        if(!started)
        {
        
        llSetStatus(STATUS_PHYSICS,TRUE);
        llMoveToTarget(start_pos,1);
        llSleep(1);
        llStopMoveToTarget();
        
        
        
        
        started=TRUE;
       }
       else
       {
           llSetStatus(STATUS_PHYSICS,FALSE);
           llStopMoveToTarget();
           llSetPos(start_pos);
           llSetRot(start_rot);
           started=FALSE;
           
        }
    
    }
    collision_start(integer num_detected)
    {
        
        llSetStatus(STATUS_PHYSICS,FALSE);
        
           llSetPos(start_pos);
           llSetRot(start_rot);
           llSetStatus(STATUS_PHYSICS,TRUE);
    }
}

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 3463 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...