Problem

Hi,

I would have this problem with my script, so i’m not sure where to put my joystick inputs.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class NewBehaviourScript : MonoBehaviour {

    // Use this for initialization
    public RCC_CarControllerV3 carController;

    public float myGasInput = 0f;
    public float mySteerInput = 0f;
    public float myBrakeInput = 0f;
    public float myHandbrakeInput = 0f;

    void Update() {

        if (!carController)
            return;

        carController.gasInput = myGasInput;
        carController.steerInput = mySteerInput;
        carController.brakeInput = myBrakeInput;
        carController.handbrakeInput = myHandbrakeInput;

    }
}

are you trying to use the joystick input to control the gasInput and steerInput?

Yes

What’s the problem?

I’m not sure where to put my joystick inputs.

Do you mean something like this?

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class NewBehaviourScript : MonoBehaviour {
    // Use this for initialization
    public RCC_CarControllerV3 carController;
    public float myGasInput = 0f;
    public float mySteerInput = 0f;
    public float myBrakeInput = 0f;
    public float myHandbrakeInput = 0f;
    void Update() {
        if (!carController)
            return;

        myGasInput = Mathf.Clamp(Input.GetAxis("Vertical"),0f,1f);
        myBrakeInput= Input.GetAxis("Break");

        carController.gasInput = myGasInput;
        carController.steerInput = mySteerInput;
        carController.brakeInput = myBrakeInput;
        carController.handbrakeInput = myHandbrakeInput;
    }
}
1 Like

Or you don’t know where to declare what your inputs should be?

Thanks!

You welcome