How do I add steering parameters to different vehicles?

Could some please advise me on what I’d need to add to be able to control how much each ship has steering? Like say ship 1 steering = good, ship 2 steering = brilliant, ship 3 steering = bad. (maybe defining it with numbers in the inspector?

PlayerInput - Pastebin.com - PlayerInput

//This script handles reading inputs from the player and passing it on to the vehicle. We
//separate the input code from the behaviour code so that we can easily swap controls
//schemes or even implement and AI "controller". Works together with the VehicleMovement script

using UnityEngine;

public class PlayerInput : MonoBehaviour
{
    public string verticalAxisName = "Vertical";        //The name of the thruster axis
    public string horizontalAxisName = "Horizontal";    //The name of the rudder axis
    public string brakingKey = "Brake";                 //The name of the brake button

    //We hide these in the inspector because we want
    //them public but we don't want people trying to change them: securuty ;)
    [HideInInspector] public float thruster;            //The current thruster value
    [HideInInspector] public float rudder;                //The current rudder value
    [HideInInspector] public bool isBraking;            //The current brake value

    void Update()
    {
        //If the player presses the Escape key and this is a build (not the editor), exit the game
        if (Input.GetButtonDown("Cancel") && !Application.isEditor)
            Application.Quit();

        //If a GameManager exists and the game is not active...
        /*if (GameManager.instance != null && !GameManager.instance.IsActiveGame())
        {
            //...set all inputs to neutral values and exit this method
            thruster = rudder = 0f;
            isBraking = false;
            return;
        }*/

        //Get the values of the thruster, rudder, and brake from the input class
        thruster = Input.GetAxis(verticalAxisName);
        rudder = Input.GetAxis(horizontalAxisName);
        isBraking = Input.GetButton(brakingKey);
    }
}

VehicleMovement - Pastebin.com - VehicleMovement

//This script handles all of the physics behaviors for the player's ship. The primary functions
//are handling the hovering and thrust calculations.

using UnityEngine;
//using System.Collections;
//using System.Collections.Generic;
//using UnityEngine.SceneManagement;
//using

public class VehicleMovement : MonoBehaviour
{
    public float speed;                        //The current forward speed of the ship

    [Header("Drive Settings")]
    public float driveForce = 17f;            //The force that the engine generates
    public float slowingVelFactor = .99f;   //The percentage of velocity the ship maintains when not thrusting (e.g., a value of .99 means the ship loses 1% velocity when not thrusting)
    public float brakingVelFactor = .95f;   //The percentage of velocty the ship maintains when braking
    public float angleOfRoll = 30f;            //The angle that the ship "banks" into a turn

    [Header("Hover Settings")]
    public float hoverHeight = 1.2f;        //The height the ship maintains when hovering
    public float maxGroundDist = 5f;        //The distance the ship can be above the ground before it is "falling"
    public float hoverForce = 100f;            //The force of the ship's hovering
    public LayerMask whatIsGround;            //A layer mask to determine what layer the ground is on
    public PIDController hoverPID;            //A PID controller to smooth the ship's hovering

    [Header("Physics Settings")]
    public Transform shipBody;                //A reference to the ship's body, this is for cosmetics
    public float terminalVelocity = 100f;   //The max speed the ship can go
    public float hoverGravity = 20f;        //The gravity applied to the ship while it is on the ground
    public float fallGravity = 80f;            //The gravity applied to the ship while it is falling

    Rigidbody rigidBody;                    //A reference to the ship's rigidbody
    PlayerInput input;                        //A reference to the player's input                   
    float drag;                                //The air resistance the ship recieves in the forward direction
    bool isOnGround;                        //A flag determining if the ship is currently on the ground

    /*[Header("Particles")]
    public ParticleSystem rearThrustersLeft;
    public ParticleSystem rearThrustersRight;
    public TrailRenderer rearThrustersTrailLeft;
    public TrailRenderer rearThrustersTrailRight;*/

    void Start()
    {
        rigidBody = GetComponent<Rigidbody>();
        input = GetComponent<PlayerInput>();
        drag = driveForce / terminalVelocity;

       
        //rearThrustersLeft.Play();
        //rearThrustersRight.Play();
        //rearThrustersTrailLeft();
        //rearThrustersTrailRight.Play();
    }

    void FixedUpdate()
    {
        speed = Vector3.Dot(rigidBody.velocity, transform.forward);
        CalculatHover();
        CalculatePropulsion();
    }

    void CalculatHover()
    {
        Vector3 groundNormal;
        Ray ray = new Ray(transform.position, -transform.up);
        RaycastHit hitInfo;
        isOnGround = Physics.Raycast(ray, out hitInfo, maxGroundDist, whatIsGround);
       
        if (isOnGround)
        {
           
            float height = hitInfo.distance;
            groundNormal = hitInfo.normal.normalized;
            float forcePercent = hoverPID.Seek(hoverHeight, height);
           
            Vector3 force = groundNormal * hoverForce * forcePercent;
            Vector3 gravity = -groundNormal * hoverGravity * height;

            rigidBody.AddForce(force, ForceMode.Acceleration);
            rigidBody.AddForce(gravity, ForceMode.Acceleration);

           
        }

        else
        {
            //This will cause our ship to self-right itself in a case where it flips over
            groundNormal = Vector3.up;
            Vector3 gravity = -groundNormal * fallGravity;
            rigidBody.AddForce(gravity, ForceMode.Acceleration);
        }

        Vector3 projection = Vector3.ProjectOnPlane(transform.forward, groundNormal);
        Quaternion rotation = Quaternion.LookRotation(projection, groundNormal);

        rigidBody.MoveRotation(Quaternion.Lerp(rigidBody.rotation, rotation, Time.deltaTime * 10f));

        float angle = angleOfRoll * -input.rudder;

        Quaternion bodyRotation = transform.rotation * Quaternion.Euler(0f, 0f, angle);
        shipBody.rotation = Quaternion.Lerp(shipBody.rotation, bodyRotation, Time.deltaTime * 10f);
    }

    void CalculatePropulsion()
    {
        float rotationTorque = input.rudder - rigidBody.angularVelocity.y;
        rigidBody.AddRelativeTorque(0f, rotationTorque, 0f, ForceMode.VelocityChange);

        //Calculate the current sideways speed by using the dot product. This tells us
        //how much of the ship's velocity is in the "right" or "left" direction
        float sidewaysSpeed = Vector3.Dot(rigidBody.velocity, transform.right);

        //Calculate the desired amount of friction to apply to the side of the vehicle. This
        //is what keeps the ship from drifting into the walls during turns. If you want to add
        //drifting to the game, divide Time.fixedDeltaTime by some amount
        Vector3 sideFriction = -transform.right * (sidewaysSpeed / Time.fixedDeltaTime);
        rigidBody.AddForce(sideFriction, ForceMode.Acceleration);

        //If not propelling the ship, slow the ships velocity
        if (input.thruster <= 0f)
        {
            rigidBody.velocity *= slowingVelFactor;

           
            //rearThrustersTrailLeft.Stop();
            //rearThrustersTrailRight.Stop();
        }

        if (!isOnGround)
            return;
       
        if (input.isBraking)
            rigidBody.velocity *= brakingVelFactor;
           

        float propulsion = driveForce * input.thruster - drag * Mathf.Clamp(speed, 0f, terminalVelocity);
        rigidBody.AddForce(transform.forward * propulsion, ForceMode.Acceleration);
    }

    void OnCollisionStay(Collision collision)
    {
        if (collision.gameObject.layer == LayerMask.NameToLayer("Wall"))
        {
            Vector3 upwardForceFromCollision = Vector3.Dot(collision.impulse, transform.up) * transform.up;
            rigidBody.AddForce(-upwardForceFromCollision, ForceMode.Impulse);
        }
    }

    public float GetSpeedPercentage()
    {
        //Returns the total percentage of speed the ship is traveling
        return rigidBody.velocity.magnitude / terminalVelocity;       
    }
}

Well, “better” steering could mean several things:

  • It could mean sharper turns, in which case you can change the amount of rotation per unit of time

  • It could mean a faster steering wheel/rudder–that is, you can more rapidly change the rate at which you are turning

  • It could mean more accurate steering, in which case bad steering could add random “noise” into your steering, causing you to drift even when you’re not pressing in any direction

  • Probably other things that haven’t occurred to me yet

The trick with computer programming is often to be extremely specific and precise about what you want to have happen. If you express your goal with sufficient clarity, the path to it often becomes obvious.

I think faster steering wheel/rudder would be the one. I’m not sure where I could change that though. I’ve made a prefab of the ship with the scripts on. I want to be able to apply that prefab multiple different times with different ship meshes/colliders and settings. such as:

Ship 1;
Steering = best
speed = best
braking = best

ship 2 ect…

I think I need to add something in one of the two scripts to be able to control how much influence pressing left or right does to the rudder/steering. What I mean is if I press left then it defaults to say 1. (1 being slow rudder/steering?) if I want it to be best steering (I’d set it to say 10?)

Where would I put it? and what would I need to change/do?
Thanks.

Right now, it looks like you’re allowing the rudder to turn as fast as the input changes. You’d need to add another layer of indirection, with a variable indicating how far the rudder is currently turned that you modify that each frame based on the current player input + vehicle’s turning quality, and then use that variable (instead of direct player input) to decide how far the ship turns in the current frame.

What sharper turns?
How would I go about implementing that?