Change font size
It is currently Fri Aug 17, 2018 7:44 am

Forum rules


{L_IMAGE}



Post a new topicPost a reply Page 1 of 1   [ 7 posts ]
Author Message
 Post subject: ODE Car (hovercraft)
PostPosted: Wed May 13, 2009 10:55 pm 
Site Admin
User avatar

Joined: Sat Feb 02, 2008 5:27 pm
Posts: 843
Ok here goes, This vehicle sorta works, its very iffy, and try not to let it go over a border.. also when you stand the vehicle will likely keep going or even shoot off, but hey it sorta works. Here is a video of this exact script in action:


Before you go rushing off dropping this script into a prim here are some very important instructions.

#1 - This script only works with ODE (OpenDynamicsEngine)
#2 - This will work with linksets but you must use the following startup procedure:
A: Rez Your vehicle
B: Move your vehicle so its hovering slightly above the ground surface
C: Edit the Prim and Set the Physical & Phantom Flags and deselect the vehicle.
D: Select vehicle again and uncheck Phantom and deselect object and let it fall to the ground
E: Reset the script in the vehicle
F: Sit on vehicle and Drive away.
***If you dont do this dont expect to move***

Also I highly Highly HIGHLY suggest you build a barrier like shown in the video other wise you will loose many vehicles off the edge of your region.
{L_CODE}:
//BE SURE TO MAKE YOUR PRIM MATERIAL GLASS BEFORE USING VEHICLE PRIM

key agent;
vector PUSH_OFF = <0, .1, .1>;
integer iChan = 0;
key owner;

integer onoff = TRUE;

string last_wheel_direction;
string cur_wheel_direction;


default
{
    state_entry()
    {

        llSetSitText("Ride");
        llSitTarget(<0.00, 0.05, 0.65>, <0.0, 0.35, 0.0, 1>);
        llSetCameraEyeOffset(<-6.0, 0.0, 3.0>);
        llSetCameraAtOffset(<3.0, 0.0, 1.0>);
    //  llSetVehicleFlags(-1);
        llSetVehicleType(VEHICLE_TYPE_CAR);
    //  llSetVehicleFlags(VEHICLE_FLAG_NO_DEFLECTION_UP | VEHICLE_FLAG_LIMIT_ROLL_ONLY | VEHICLE_FLAG_LIMIT_MOTOR_UP);
        llSetVehicleFloatParam(VEHICLE_ANGULAR_DEFLECTION_EFFICIENCY, 1.00);
        llSetVehicleFloatParam(VEHICLE_LINEAR_DEFLECTION_EFFICIENCY, 1.0);
        llSetVehicleFloatParam(VEHICLE_ANGULAR_DEFLECTION_TIMESCALE, 0.01);
        llSetVehicleFloatParam(VEHICLE_LINEAR_DEFLECTION_TIMESCALE, 0.01);
         
        llSetVehicleFloatParam(VEHICLE_LINEAR_MOTOR_TIMESCALE, 0.1);
        llSetVehicleFloatParam(VEHICLE_LINEAR_MOTOR_DECAY_TIMESCALE, 0.1);
        llSetVehicleFloatParam(VEHICLE_ANGULAR_MOTOR_TIMESCALE, 1.0);
        llSetVehicleFloatParam(VEHICLE_ANGULAR_MOTOR_DECAY_TIMESCALE, 0.1);
       
       
        llSetVehicleVectorParam(VEHICLE_LINEAR_FRICTION_TIMESCALE, <100.0, 10.0, 100.0>);
        llSetVehicleVectorParam(VEHICLE_ANGULAR_FRICTION_TIMESCALE, <100.0, 10.0, 100.0>);
       
       
        llSetVehicleFloatParam(VEHICLE_VERTICAL_ATTRACTION_EFFICIENCY, 1.0);
        llSetVehicleFloatParam(VEHICLE_VERTICAL_ATTRACTION_TIMESCALE, 1.0);
       
        llSetVehicleFloatParam(VEHICLE_BANKING_EFFICIENCY, 1.0);
        llSetVehicleFloatParam(VEHICLE_BANKING_TIMESCALE, 0.1);
       
        owner = llGetOwner();
        llListen(iChan,"",owner,"");
    }
   
    changed(integer change)
    {
        if (change & CHANGED_LINK)
        {
            key agent = llAvatarOnSitTarget();
            if (agent)
            {
                if (agent != llGetOwner())
                {
                  //  llSay(0, "You aren't the owner");
                 //   llUnSit(agent);
                //    llPushObject(agent, <0,0,100>, ZERO_VECTOR, FALSE);
                }
                else
                {
                 //   llSleep(4.5);
                    llSetStatus(STATUS_PHYSICS | STATUS_ROTATE_X | STATUS_ROTATE_Y | STATUS_ROTATE_Z, TRUE);
                  //  llSleep(.1);
                  //  llSetTimerEvent(1.0);
                    llRequestPermissions(agent, PERMISSION_TRIGGER_ANIMATION | PERMISSION_TAKE_CONTROLS);
                }
            }
            else
            {
                llSetTimerEvent(0);
                llStopSound();
                llSetStatus(STATUS_PHYSICS | STATUS_ROTATE_X | STATUS_ROTATE_Y | STATUS_ROTATE_Z, FALSE);
                llReleaseControls();
                llStopAnimation("motorcycle_sit");
                llPushObject(llGetOwner(), PUSH_OFF, <0,0,0>, TRUE);
            }
        }
       
    }
   
    run_time_permissions(integer perm)
    {
        if (perm)
        {
            llStartAnimation("motorcycle_sit");
            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;
        vector vel = llGetVel();
       
        if(level & CONTROL_FWD)
        {

            if(!llGetStatus(STATUS_PHYSICS))
            {
                llSetStatus(STATUS_PHYSICS | STATUS_ROTATE_X | STATUS_ROTATE_Y | STATUS_ROTATE_Z, TRUE);

            }
           
           llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION, <15,0,0>);
        }
        if(level & CONTROL_BACK)
        {

            llSetVehicleRotationParam(VEHICLE_REFERENCE_FRAME, <0, 0, 1, 0> ); 
            if(!llGetStatus(STATUS_PHYSICS))
            {
                llSetStatus(STATUS_PHYSICS | STATUS_ROTATE_X | STATUS_ROTATE_Y | STATUS_ROTATE_Z, TRUE);

            }
            llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION, <-5,0,0>);
        }

        if(level & (CONTROL_RIGHT|CONTROL_ROT_RIGHT))
        {

            llSetVehicleRotationParam(VEHICLE_REFERENCE_FRAME, <0, 0, 0, 3> );
            angular_motor.x += 1;
            angular_motor.z -= 1;
        }
        if(level & (CONTROL_LEFT|CONTROL_ROT_LEFT))
        {

            llSetVehicleRotationParam(VEHICLE_REFERENCE_FRAME, <0, 0, 0, 3> );
            angular_motor.x -= 1;
            angular_motor.z += 1;
            //llWhisper(0,(string)llGround(<0,0,0>) + " -- " + (string)llGetPos());
        }
        if(level & (CONTROL_UP))
        {
            llSetVehicleRotationParam(VEHICLE_REFERENCE_FRAME, <0, 0, 0, 1> );
            angular_motor.y -= 1;
        }
        if(level & (CONTROL_DOWN))
        {
            llSetVehicleRotationParam(VEHICLE_REFERENCE_FRAME, <0, 0, 0, 1> );
            angular_motor.y += 1;
        }
        if((edge & CONTROL_FWD) && (level & CONTROL_FWD))
        {
            // We have a few message links to communicate to the other
            // scritps when we start to accelerate and let off the gas.
            llMessageLinked(LINK_SET, 0, "burst", "");
        }
        if((edge & CONTROL_BACK) && !(level & CONTROL_BACK))
        {

        }

        llSetVehicleVectorParam(VEHICLE_ANGULAR_MOTOR_DIRECTION, angular_motor);
       
    }
        timer()
    {

    }
   
}


If you improve upon this script, please let us know, post your versions here for testing too.

Enjoy,

Neb :ugeek:


Top
 Profile  
 
 Post subject: Re: ODE Car (hovercraft)
PostPosted: Mon Aug 10, 2009 9:15 pm 

Joined: Thu May 14, 2009 11:03 pm
Posts: 3
Some things seem not to work. Not on this car. On the vehicle functions.

Linear friction in the Y direction does not work with boats. One can turn the heading of the boat and velocity in the original direction remains.

Buoyancy not working, but that's easily dealt with. The lack of 3D linear friction is bad. I can make a friction model, but shrug.


Top
 Profile  
 
 Post subject: Re: ODE Car (hovercraft)
PostPosted: Wed Aug 12, 2009 1:39 pm 

Joined: Mon Jan 12, 2009 5:03 pm
Posts: 24
Nebadon Izumi {L_WROTE}:
Ok here goes, This vehicle sorta works, its very iffy, and try not to let it go over a border.. also when you stand the vehicle will likely keep going or even shoot off, but hey it sorta works.


thats nice/great work and good news for some of us .. but you know .. they demand "moar" :P
( for me it is ok to walk and fly and TP .. )


Top
 Profile  
 
 Post subject: Re: ODE Car (hovercraft)
PostPosted: Wed Dec 23, 2009 10:30 am 
Furious Typer

Joined: Fri Dec 11, 2009 10:24 am
Posts: 52
I am working on script for car ... seeing similar problems to you
but found this is handy - using the avatar size to detect if they are seating or unseating - ie if its zero the avatar has gone so stop the car

key agent = llAvatarOnSitTarget();

vector size = llGetAgentSize(agent);
if(size.x>0)
{
llSetStatus(STATUS_PHYSICS, TRUE);
... other stuff
}
else
{
llSetStatus(STATUS_PHYSICS, FALSE);
... other stuff
}
I have found this reliably stops the car when you stand up ( or is that bail out for dear life! LOL )


Top
 Profile  
 
 Post subject: Re: ODE Car (hovercraft)
PostPosted: Wed Dec 23, 2009 10:56 am 
OSG Elite
User avatar

Joined: Wed Mar 11, 2009 3:57 pm
Posts: 444
Tasha, you should check out OKC Sandbox.

There is new vehicles there with teh latest code that works a charm. nebadon has placed out several that you can get a full perm copy of. Take one for a drive and have a blast. The Above code is pretty much deprecated as things have changed a lot in recent months.

_________________
No further support of any kind, for any of my materials. Use as/is whereis.
PLEASE UNSTICKY Any Stickied Posting by myself.


Top
 Profile  
 
 Post subject: Re: ODE Car (hovercraft)
PostPosted: Wed Dec 23, 2009 11:18 am 
Furious Typer

Joined: Fri Dec 11, 2009 10:24 am
Posts: 52
Many Thanks
Going There now !


Top
 Profile  
 
 Post subject: Re: ODE Car (hovercraft)
PostPosted: Thu Dec 24, 2009 2:38 am 
Furious Typer

Joined: Fri Dec 11, 2009 10:24 am
Posts: 52
Definitely a long way ahead of mine
I will keep going ... maybe we will race one day
lol


Top
 Profile  
 
Display posts from previous:  Sort by  
Post a new topicPost a reply Page 1 of 1   [ 7 posts ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  


Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
610nm Style by Daniel St. Jules of Gamexe.net