What I am trying to do is make an airplane pitching system to pitch up once it recieves vertical input.
PS: Please note that I am a noob/beginner and I'm not the best programmer ever so if I make an obvious mistake( Which I probably did), just know it is from a noob
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class playerControllerX : MonoBehaviour
{
private float rotateSpeed = 5f;
private float horizontalInput;
public float forwardInput;
void Start()
{
}
void Update()
{
horizontalInput = Input.GetAxis("Horizontal");
rotateInput = Input.GetAxis("Vertical") * rotateSpeed * Time.deltaTime;
}
void LateUpdate()
{
transform.Rotate(0, rotateInput ,0);
}
}
all errors:
Assets/Scripts/playerController.cs(18,9): error CS0103: The name 'rotateInput' does not exist in the current context
Assets/Scripts/playerController.cs(25,29): error CS0103: The name 'rotateInput' does not exist in the current context
'rotateInput' does not exist in the current context means that you haven't declared it. Here's I think, what you're trying to do. I've modified it
private float rotateSpeed = 5f;
private float playerInput; //declaration
void Update()
{
playerInput = Input.GetAxis("Vertical");
// "Vertical" <---> x axis
transform.Rotate(Vector3.right*rotateSpeed*playerInput);
// Vector3.right <--->direction
}
This allows you to rotate object on an axis in the direction specified. But there are better ways to deal with rotation like Quaternions, Addtorque() (depends on requirement) that you can research.