Search Unity

Question Who can help me solve my problem?

Discussion in 'Editor & General Support' started by Deleted User, Apr 18, 2021.

  1. Deleted User

    Deleted User

    Guest

    Eror:

    ArgumentException: Input Axis Harizontal is not setup.
    To change the input settings use: Edit -> Settings -> Input
    DroneMovementScript.Swerwe () (at Assets/DroneMovementScript.cs:99)
    DroneMovementScript.FixedUpdate () (at Assets/DroneMovementScript.cs:19)


    Software:

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

    public class DroneMovementScript : MonoBehaviour
    {

    Rigidbody ourDrone;

    void Awake(){
    ourDrone = GetComponent<Rigidbody>();
    }

    void FixedUpdate()
    {
    MovementUpDown();
    MovementForward();
    Rotation();
    Swerwe();

    ourDrone.AddRelativeForce(Vector3.up * upForce);
    ourDrone.rotation = Quaternion.Euler(
    new Vector3(tiltAmountForward, currentYRotation, tiltAmountSideways)
    );
    }

    public float upForce;
    void MovementUpDown()
    {
    if (Input.GetKey(KeyCode.I))
    {
    upForce = 450;
    }
    else if (Input.GetKey(KeyCode.K))
    {
    upForce = -200;
    }
    else if (!Input.GetKey(KeyCode.I) && !Input.GetKey(KeyCode.K))
    {
    upForce = 98.1f;
    }
    }

    private float movementForwardSpeed = 500.0f;
    private float tiltAmountForward = 0;
    private float titltVelocityForward;
    void MovementForward()
    {
    if(Input.GetAxis("Vertical") != 0) {
    ourDrone.AddRelativeForce(Vector3.forward * Input.GetAxis("Vertical") * movementForwardSpeed);
    tiltAmountForward = Mathf.SmoothDamp(tiltAmountForward, 20 * Input.GetAxis("Vertical"), ref titltVelocityForward, 0.1f);
    }
    }

    private float wantedYRotation;
    private float currentYRotation;
    private float rotateAmoutByKeys = 2.5f;
    private float rotationYVelocity;
    void Rotation()
    {
    if (Input.GetKey(KeyCode.A))
    {
    wantedYRotation -= rotateAmoutByKeys;
    }
    if (Input.GetKey(KeyCode.D))
    {
    wantedYRotation += rotateAmoutByKeys;
    }

    currentYRotation = Mathf.SmoothDamp(currentYRotation, wantedYRotation, ref rotationYVelocity, 0.25f);
    }

    private Vector3 velocityToSmoothDampToZero;
    void ClampingSpeedValues()
    {
    if (Mathf.Abs(Input.GetAxis("Vertical")) > 0.2f && Mathf.Abs(Input.GetAxis("Harizontal")) > 0.2f)
    {
    ourDrone.velocity = Vector3.ClampMagnitude(ourDrone.velocity, Mathf.Lerp(ourDrone.velocity.magnitude, 10.0f, Time.deltaTime * 5F));
    }
    if (Mathf.Abs(Input.GetAxis("Vertical")) > 0.2f && Mathf.Abs(Input.GetAxis("Harizontal")) < 0.2f)
    {
    ourDrone.velocity = Vector3.ClampMagnitude(ourDrone.velocity, Mathf.Lerp(ourDrone.velocity.magnitude, 10.0f, Time.deltaTime * 5F));
    }
    if (Mathf.Abs(Input.GetAxis("Vertical")) < 0.2f && Mathf.Abs(Input.GetAxis("Harizontal")) > 0.2f)
    {
    ourDrone.velocity = Vector3.ClampMagnitude(ourDrone.velocity, Mathf.Lerp(ourDrone.velocity.magnitude, 5.0f, Time.deltaTime * 5F));
    }
    if (Mathf.Abs(Input.GetAxis("Vertical")) < 0.2f && Mathf.Abs(Input.GetAxis("Harizontal")) < 0.2f)
    {
    ourDrone.velocity = Vector3.SmoothDamp(ourDrone.velocity, Vector3.zero, ref velocityToSmoothDampToZero, 0.95f);
    }
    }

    private float sideMovementAmount = 300.0f;
    private float tiltAmountSideways;
    private float tiltAmoutVelocity;
    void Swerwe()
    {
    if(Mathf.Abs(Input.GetAxis("Harizontal")) > 0.2f)
    {
    ourDrone.AddRelativeForce(Vector3.right * Input.GetAxis("Harizontal") * sideMovementAmount);
    tiltAmountSideways = Mathf.SmoothDamp(tiltAmountSideways, -20 * Input.GetAxis("Harizontal"), ref tiltAmoutVelocity, 0.1f);
    }
    else
    {
    tiltAmountSideways = Mathf.SmoothDamp(tiltAmountSideways, 0, ref tiltAmoutVelocity, 0.1f);
    }
    }

    }



    My software and eror is above. Who can help me solve my problem?
     
  2. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,741
    This part seems fairly clear. Did you attempt to do that?
     
  3. Deleted User

    Deleted User

    Guest

    I could not understand how to do what was written there.
     
  4. Deleted User

    Deleted User

    Guest

    I came to the place in the picture, does anyone know what to do next?
     

    Attached Files:

  5. Vryken

    Vryken

    Joined:
    Jan 23, 2018
    Posts:
    2,106
    Make sure you spell the name of the input correctly in your script.

    "ArgumentException: Input Axis Harizontal is not setup." -> It should be Horizontal.
     
    Deleted User likes this.
  6. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,695