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();
}
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?