Bioscope Posted March 15, 2021 Share Posted March 15, 2021 Hey! Decided to create an airplane. In the flight, everything is fine. The problem starts when I try to drive on the ground, let alone water. In general, I need a taxi mode. How to do it? Thanks! 😊 Link to comment Share on other sites More sharing options...
Quistess Alpha Posted March 16, 2021 Share Posted March 16, 2021 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. 1 Link to comment Share on other sites More sharing options...
Bioscope Posted March 16, 2021 Author Share Posted March 16, 2021 (edited) 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 March 16, 2021 by Bioscope Link to comment Share on other sites More sharing options...
Bioscope Posted March 16, 2021 Author Share Posted March 16, 2021 And yes I know all airplane scripts are Cubey's script based, but mine is generated by a vehicle script generator, so I consider it mine. Link to comment Share on other sites More sharing options...
Chroma Starlight Posted March 16, 2021 Share Posted March 16, 2021 (edited) 3 hours ago, Bioscope said: I would hire a scripter, but I want to understand what is going on and I think it will be very expensive. 😉 Learning doesn't have to be expensive. How about http://wiki.secondlife.com/wiki/Linden_Vehicle_Tutorial ? Edited March 16, 2021 by Chroma Starlight 1 Link to comment Share on other sites More sharing options...
Quistess Alpha Posted March 16, 2021 Share Posted March 16, 2021 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. 1 Link to comment Share on other sites More sharing options...
Bioscope Posted March 16, 2021 Author Share Posted March 16, 2021 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 More sharing options...
Quistess Alpha Posted March 16, 2021 Share Posted March 16, 2021 well then the problem becomes a sort of "how do I determine if a thing is a runway or a bird" problem. you couldtry to do a llSensorRepeat() and test for unscripted things below you that are of a certain size perhaps. 1 Link to comment Share on other sites More sharing options...
Evah Baxton Posted March 16, 2021 Share Posted March 16, 2021 (edited) 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 March 16, 2021 by Evah Baxton 1 1 Link to comment Share on other sites More sharing options...
Bioscope Posted March 17, 2021 Author Share Posted March 17, 2021 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 More sharing options...
Quistess Alpha Posted March 17, 2021 Share Posted March 17, 2021 (edited) 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 March 17, 2021 by Quistessa 1 1 Link to comment Share on other sites More sharing options...
Bioscope Posted March 17, 2021 Author Share Posted March 17, 2021 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 More sharing options...
Evah Baxton Posted March 17, 2021 Share Posted March 17, 2021 (edited) 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 March 17, 2021 by Evah Baxton 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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