Jump to content

First attempt at water floating object


Raena Parx
 Share

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

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

Recommended Posts

Hi All,

I have three questions :)

(1) I decided to try making my own floatie, something similar to the purple inner tube, but my own build.  I used the To0b script that came with the freebie as a starting place.  For the most part it works. However I am sinking about 5 inches deeper into the water than I should be and it looks like i'm drowning lol.  The object turns physical when sat on.  I've tried several things including changing physical property type, hover height, boyancy, and gravity (which sent me flying into the air haha).  Anyway, I cant seem to what parameter needs changing to make me float just a little bit higher in the water.

(2) 2nd problem...any time I change a parameter in the script while its on water, the object becomes dead...unfloatable, as if the script died.  I tried resetting script and setting script to running (just in case), but once it's dead that's the end of it.  Any suggestions here as well?

(3) Am trying to add a collision sound when it bumps into things.  Tried using    CollsionSound("MySound,1.0);    but it only sounded when jumping off the object, and not when it bumped into something.

Any help is greatly appreciated.

Here is the script:

==================
// by Ben
// Some help from Casval and Dave
rotation rot;
key owner;
reset()
{
    vector pos = llGetPos();
    pos.z = pos.z + 2.0;
    llMoveToTarget(pos, 0.3);
    llRotLookAt(rot, 0.1, 1.0);
    llSleep(1.0);
    llStopLookAt();
    llStopMoveToTarget();
}
     
default
{    

    state_entry()
    {
        llSetSoundQueueing(FALSE);
        llPassCollisions(TRUE);
        llSetSitText("Ride");
        
        llSitTarget(<-0.37, 0.00, -0.01>, <0.00000, -0.25882, 0.00000, 0.47>);
        // <bkwd/fwd , left/right , up/down> , <rotation, rotation, rotation>
        
        llSetCameraEyeOffset(<-4.0, 0.0, 5.00>);
        llSetCameraAtOffset(<0.0, 0.0, 1.0>);
        
        llSetVehicleType(VEHICLE_TYPE_CAR);
        llRemoveVehicleFlags(-1);
        
        llSetVehicleFlags(VEHICLE_FLAG_HOVER_WATER_ONLY | VEHICLE_FLAG_HOVER_UP_ONLY | VEHICLE_FLAG_NO_DEFLECTION_UP);
        
        llSetVehicleFloatParam(VEHICLE_ANGULAR_DEFLECTION_EFFICIENCY, 0.2);
        llSetVehicleFloatParam(VEHICLE_LINEAR_DEFLECTION_EFFICIENCY, 0.2);
        llSetVehicleFloatParam(VEHICLE_ANGULAR_DEFLECTION_TIMESCALE, 1.0);
        llSetVehicleFloatParam(VEHICLE_LINEAR_DEFLECTION_TIMESCALE, 1000.0);
        
        llSetVehicleFloatParam(VEHICLE_LINEAR_MOTOR_TIMESCALE, 1.0);
        llSetVehicleFloatParam(VEHICLE_LINEAR_MOTOR_DECAY_TIMESCALE, 0.1);
        llSetVehicleFloatParam(VEHICLE_ANGULAR_MOTOR_TIMESCALE, 0.1);
        llSetVehicleFloatParam(VEHICLE_ANGULAR_MOTOR_DECAY_TIMESCALE, 0.1);
        
        llSetVehicleVectorParam(VEHICLE_LINEAR_FRICTION_TIMESCALE, <10, 10, 10.0>);
        llSetVehicleVectorParam(VEHICLE_ANGULAR_FRICTION_TIMESCALE, <10.0, 10.0, 10>);
        
        llSetVehicleFloatParam(VEHICLE_VERTICAL_ATTRACTION_EFFICIENCY, 0.2);
        llSetVehicleFloatParam(VEHICLE_VERTICAL_ATTRACTION_TIMESCALE, 0.5);        
        
        llSetVehicleFloatParam(VEHICLE_BUOYANCY, 0);
        llSetVehicleFloatParam(VEHICLE_HOVER_HEIGHT, 0.1);
        llSetVehicleFloatParam(VEHICLE_HOVER_EFFICIENCY, 0.5);
        
        llSetVehicleFloatParam(VEHICLE_HOVER_TIMESCALE, 0.1);      
        llSetVehicleFloatParam(VEHICLE_BANKING_EFFICIENCY, 0.1);
        llSetVehicleFloatParam(VEHICLE_BANKING_TIMESCALE, 0.01);
        llSetVehicleFloatParam(VEHICLE_BANKING_MIX, 1.0);
        
        //llCollisionSound("", 0.0);
    }
    
    on_rez(integer param)
    {
       // if(owner != llGetOwner())
       // {
           // owner = llGetOwner();
            //llGiveInventory(agent, "Innertube Instructions");
        //}
    }
    
    changed(integer change)
    {
        if (change & CHANGED_LINK)
        {
            key agent = llAvatarOnSitTarget();
            //llGiveInventory(agent, "Tubing Gnoma");
            if (agent)
            {
                //if (agent != llGetOwner())
                //{
                 //   llSay(0, "You aren't the owner");
                 //   llUnSit(agent);
                 //   llPushObject(agent, <0,0,100>, ZERO_VECTOR, FALSE);
               //}
               // else
               // {
                    llSetStatus(STATUS_PHYSICS, TRUE);
                    llRequestPermissions(agent, PERMISSION_TRIGGER_ANIMATION | PERMISSION_TAKE_CONTROLS);
        
                    llMessageLinked(LINK_SET, 0, "on", "");
                    llSetTimerEvent(1.0);
                //}
        }
            else
            {
                llSetStatus(STATUS_PHYSICS, FALSE);
                llReleaseControls();
                
                //llStopAnimation("crouch");
                llMessageLinked(LINK_SET, 0, "off", "");
                llSetTimerEvent(0.0);
                llStopSound();
            } 
        }
        
    }
    
    run_time_permissions(integer perm)
    {
        if (perm)
        {
            //llStopAnimation("sit");
            //llStartAnimation("crouch");
            llTakeControls(CONTROL_FWD | CONTROL_BACK | CONTROL_RIGHT | CONTROL_LEFT | CONTROL_ROT_RIGHT | CONTROL_ROT_LEFT | CONTROL_UP | CONTROL_DOWN, TRUE, FALSE);
        }
    }
    
    control(key id, integer level, integer edge)
    {
        vector angular_motor;
        
        if(level & CONTROL_FWD)
        {   
                llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION, <4, 0, 0>);
                llStartAnimation("falldown");
        }
        if(level & CONTROL_BACK)
        {
            
            llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION, <-4,0,0>);
            llStartAnimation("falldown");
        }
       
        if(level & (CONTROL_RIGHT|CONTROL_ROT_RIGHT))
        {
            
            angular_motor.z = -PI * 0.25;
            llStartAnimation("falldown");
            
        }
        if(level & (CONTROL_LEFT|CONTROL_ROT_LEFT))
        {
           
            angular_motor.z = PI * 0.25;
            llStartAnimation("falldown");
            
        }
        if(level & (CONTROL_DOWN))
        {
            //reset();
        }
        else if(level == FALSE)
        {
            llStopAnimation("falldown");
        }
        llSetVehicleVectorParam(VEHICLE_ANGULAR_MOTOR_DIRECTION, angular_motor);
    }
    
    timer()
    {
        vector pos = llGetPos();
        if(( pos.z - llGround(ZERO_VECTOR) ) < 0.8)
        {
            rot = llGetRot();
        }
    }
      
    
}
==================

Thank you.

Raena Parx

Edited by Raena Parx
added details
Link to comment
Share on other sites

As a sort of generic response, I would say that although you can certainly script a floatie as a vehicle, that's usually overkill.  IMO, it's much easier to script a floatie as a simple physical object that gets shoved around randomly by occasional bumps from llApplyImpulse statements in a timer event.  I'm sure that a quick Google search will turn up freebie raft scripts that work that way.

I suspect that the reason your script stalls after you edit it is that is had lost the permissions that you approved, so it needs to go back to square one.  That wouldn't normally be a problem, but your run_time_permissions event is triggered by commands in the changed event when you sit on the raft.  If you're already sitting on the raft, the changed event won't fire.  You have to get off the raft and sit down again.  Then it should work.  Parenthetically, if you wrote a simpler script that didn't require using controls, you could get away with asking permissions only for PERMISSION TRIGGER_ANIMATION, and the problem would mostly go away.

llCollisionSound is kind of flaky, in my experience.   Not because of the function itself but mostly because collision* events get triggered at unpredictable times.  If you want to record collisions with the edge of the pond, you might consider using a land_collision* event to trigger the sound.  If you expect to collide with specific objects, you could filter for them and ignore collisions with your av too. 

 

Link to comment
Share on other sites

Thank you Rolig.  I like the vehicle because it lets the user paddle in whatever direction they want to go.  Not sure a raft script would work for that.

Thank you for explaining the run_time_permissions thing.  That makes sense.  Will play with that some more.

I did notice the land_collision function, but what I really want is when multiple users are on the floaties and they collide it would make a collision sound. so the land_collision wouldn't be the answer.

Any idea how to make the floatie float a little higher in the water?  Looks like I'm sinking lol. 

 

Thank you again for your help.  :) 

Link to comment
Share on other sites

1 hour ago, Raena Parx said:

what I really want is when multiple users are on the floaties and they collide it would make a collision sound. so the land_collision wouldn't be the answer.

While llCollisionSound does change the sound made by a collision, in my experience the sound isn't made unless the collision is hard enough.

You should use the collision_start event for doing stuff on any kind of collision with anything BUT land.

Also to change the float height, change VEHICLE_HOVER_HEIGHT from 0.1 to something higher.

Link to comment
Share on other sites

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