Jump to content

Airplane


Bioscope
 Share

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

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

Recommended Posts

I happen to have a full-perm bike that has a flying mode, which is basically the opposite of what you want lol. glancing over it's script it has a separate state for 'ground' driving and 'air' flying (each with their own state_entry() control() and listen() events and such) if you were clever about it you could probably get away with writing a some global functions that would reset all the vehicle parameter stuff for different modes of operation, which might cut down on some code duplication.

  • Like 1
Link to comment
Share on other sites

10 hours ago, Quistessa said:

I happen to have a full-perm bike that has a flying mode, which is basically the opposite of what you want lol. 

Hi! Thanks! But I think in your script the change of modes does not happen automatically, but manually? I saw something similar in a script I found on the Help island. Which is very interesting, but not what I need. I've probably tried all the open source scripts and none of them suit me *. I like RCX scripts, but they are too complicated for me, and I do not understand what is going on in them. I would hire a scripter, but I want to understand what is going on and I think it will be very expensive. 😉

* Precisely for the same reason, there is no taxi mode. So I make my own script.

 

Edited by Bioscope
Link to comment
Share on other sites

Ahh, if you want to 'automatically' transition from land to air or visa versa, you need to try and devise some sort of test that determines when you should go from one to the other, for example, perhaps when you're flying if you're less than 50 linden-units off the ground, transition to either the land or water state.

timer()
{
	integer groundLevel = llGround(ZERO_VECTOR);
	integer waterLevel  = llWater(ZERO_VECTOR);
  	vector myPosition = llGetPos();

  	if(waterLevel > groundLevel)
	{
		if(myPosition.z - waterLevel < 50  )
			state boat; 
	}else // ground level is higher.
	{
		if(myPosition.z - groundLevel < 50 )
			state vehicle; // or whatever function to land the
	}
}

you would also want to be sure not to start the test until you got a bit above 50 units off the ground/water (say 75 units), so you don't immediately fall right after taking off. for going  from driving/boating to flying, you might devise some sort of speed-based test.

  • Thanks 1
Link to comment
Share on other sites

4 hours ago, Quistessa said:

Ahh, if you want to 'automatically' transition from land to air or visa versa.

Many thanks! This is a very interesting example. But what if, say, the runway is in the air above water or land? It is obvious that the vehicle will continue to behave as if it were in flight? What to do about it? 🤔

Link to comment
Share on other sites

You could try a ray.

float updateFreq = 0.5; //How often the ray checks for ground
float rayLength = 0.25; //How far down the ray looks for ground

default
{
    state_entry()
    {
        llSetTimerEvent(updateFreq);
    }
    
    timer()
    {
        vector start = llGetPos();
        vector end = start - <0.0, 0.0, rayLength>;
        list results = llCastRay(start, end, [RC_MAX_HITS, 1] );
        if(llList2String(results, 0)=="0") {
            //Set flying state
            llSetText("AIR",<1.0,0,1.0>,1.0);
        } else {
            //Set grounded state
            llSetText("GROUND",<1.0,0,1.0>,1.0);
        }
    }
}

 

Edited by Evah Baxton
  • Like 1
  • Thanks 1
Link to comment
Share on other sites

13 hours ago, Evah Baxton said:

You could try a ray.

Thanks for this example! I tried it, but in flight, especially in turns, it keep saying AIR - GROUND - AIR - GROUND especially on turns. Do I understand correctly that it detects itself, the lower parts of the airplane such as the gears? And what to do in this case? Do I need to put this script in the very bottom prim of the airplane and from there send a link message to the engine script?

Or... what am I doing wrong? Also wondering what parameters need to be changed? So far this is what I got, but I have not tried it on the water. ;)

        vector start = llGetPos();
        vector end = start - < 0.0, 0.0, rayLength > ;
        list results = llCastRay(start, end, [RC_MAX_HITS, 1]);
        if (llList2String(results, 0) == "0")
        {
            //Set flying state
            llSetText("AIR", < 1.0, 0, 1.0 > , 1.0);
            llSetVehicleFloatParam(VEHICLE_ANGULAR_MOTOR_TIMESCALE, 1.20);
            llSetVehicleFloatParam(VEHICLE_VERTICAL_ATTRACTION_EFFICIENCY, 0.20);
        }
        else
        {
            //Set grounded state
            llSetText("GROUND", < 1.0, 0, 1.0 > , 1.0);
            llSetVehicleFloatParam(VEHICLE_ANGULAR_MOTOR_TIMESCALE, 10.0);
            llSetVehicleFloatParam(VEHICLE_VERTICAL_ATTRACTION_EFFICIENCY, 1.00);
        

 

Link to comment
Share on other sites

Yeah, it's probably detecting itself. you could get around that by making 'start' a bit lower than your actual position:

vector start = llGetPos()-<0.0, 0.0, HullRadius+Fudge>;

where HullRadius+fudge is a float slightly larger than the distance between your vehicle's center and its underside.

Edit: a bit of a nitpick, but you probably want to do a lot more than just setting 2 vehicle params to change the state. I would reccomend making some global functions to hold all the stuff you do to change the vehicle type

Edited by Quistessa
  • Like 1
  • Thanks 1
Link to comment
Share on other sites

56 minutes ago, Quistessa said:

Yeah, it's probably detecting itself. you could get around that by making 'start' a bit lower than your actual position:

vector start = llGetPos()-<0.0, 0.0, HullRadius+Fudge>;

where HullRadius+fudge is a float slightly larger than the distance between your vehicle's center and its underside.

Edit: a bit of a nitpick, but you probably want to do a lot more than just setting 2 vehicle params to change the state. I would reccomend making some global functions to hold all the stuff you do to change the vehicle type

Wow! Thank you so much!

Just one more question: how can I add water detection here so that the airplane behaves the same on the water as it does on the ground? Can raycast detect water?

:)

 

Link to comment
Share on other sites

Land returns a NULL_KEY, but water doesn't appear to return anything.

Take a look at this:

http://wiki.secondlife.com/wiki/LlWater

Looks like you could use this to find out if your plane is below or at the surface of the water (in order to change modes.)

Quote

behaves the same on the water as it does on the ground

You'll have to mess around with buoyancy for this mode. I don't think it will act exactly as it does on land. It will need to act like a boat / seaplane.

Edited by Evah Baxton
  • Like 1
Link to comment
Share on other sites

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