Jump to content

Airbrake


Recommended Posts

My first plugin - airbrake. Turns on with 'B' key. It uses the way to activate that similar to the MuMech code.

Will be useful when return from space for additional brake in atmosphere.

891e2501a29f90ccc95df5bbd5619acd.jpeg

334bfff80cad85fd74a971b7b8e46f67.jpeg

f9d84fee3899f647d0857290b2616ace.jpeg

Code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;

namespace AirB
{
public class Airbrake : Part
{
private bool Active = false; //Toggle bool
private float on_drag = 5F;
private float on_drag_min = 4F;
private float off_drag = 0.1F; //Drag parameters

protected override void onPartStart() //Turn off when start
{
transform.FindChild('model').FindChild('off').renderer.enabled = true;
transform.FindChild('model').FindChild('on').renderer.enabled = false;
}

protected override void onPartUpdate()
{
base.onPartUpdate();

if (Input.GetKeyDown(KeyCode.)
{
if (Active == false) //Turn on
{
transform.FindChild('model').FindChild('on').renderer.enabled = true; //Make 'on' model visible, and make 'off' model invisible
transform.FindChild('model').FindChild('off').renderer.enabled = false;
maximum_drag = on_drag; //Change drag
minimum_drag = on_drag_min;
Active = true; //Change toggle bool
}


else //Turn off
{
transform.FindChild('model').FindChild('off').renderer.enabled = true; //Make 'off' model visible, and make 'on' model invisible
transform.FindChild('model').FindChild('on').renderer.enabled = false;
maximum_drag = minimum_drag = off_drag; //Change drag
Active = false; //Change toggle bool
}
}
}
}
}

Download:

http://205.196.123.169/97k71zbno7cg/v80texlsq7cglci/Airbrake.rar

Link to comment
Share on other sites

Very nice. Might I suggest something more complex as a next project?

Many planes are fitted with control surfaces that could be used as airbrakes themselves, if only the game would control them accordingly. Many setups would impart a translation force on the plane, but for some situations this is okay, and some planes could cancel that translation force entirely. The trick is to adjust the control surfaces so that the torque produced isn\'t changed, but a large force is applied to slow down the plane.

Link to comment
Share on other sites

This looks too good. What a great thing to return to after a week in a muddy, cold campsite!

Can\'t download just yet so I must ask: can you change the brake toggle from the \'B\' key?

Link to comment
Share on other sites

This is awesome for my ballistic Minimus return probes! I usually mount just barely enough engines to put them into a return trajectory, but the downside of that sometimes is insufficient thrust to slow down enough for parachutes to slow the ship down; now I can watch my probe hurtle in nose first, pop aerobrakes, and slow down enough to survive landing!

Link to comment
Share on other sites

Change

Input.GetKeyDown(KeyCode.

to

Input.GetKeyDown(key.ToLowerInvariant())

and add

string key = 'b';

to your params list at the top.

This way, it could be configured in the part.cfg!

Thanks, but I knew it ;)

I can\'t make my airbrake rotate around it\'s Z-axis. I\'ll try to make it with Transform.InverseTransformDirection.

I\'m working now on Shuttle airbrake. It will look like Space Shuttle rudder brake, and yes, there will be cuctom key binding ;) And there will also rudder turning.

Link to comment
Share on other sites

Yep, tested this out and it is absolutely perfect in terms of crude, basic speed-braking in midair. I can now do diving approaches a la C-130 on KSP! Thank you!

Link to comment
Share on other sites

  • 2 weeks later...
  • 2 months later...

He was asking for help. I think that's a little different than necroing "hey guys his sucks!" three months after the last post.

But anyways, after you extract the .rar with winzip or something like it, tere will be a parts folder and a plugins folder. Drop them in your main ksp folder and say yes if it asks you to merge the folders.

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...