I need a flight script where the object moves forward automatically . W moves up, S moves down, A moves the object on the left and rotates it to the left as well and the same things for the right side and the key should be D. Need help guys
Great, so what have you tried so far? What’s not working about it? Are we talking 2D, 3D?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class FlightMode : MonoBehaviour
{
public Rigidbody rb;
void Start()
{
rb.useGravity = false;
}
// Update is called once per frame
void Update()
{
transform.position += transform.right * 90f;
transform.Rotate(-Input.GetAxis("Horizontal"), 0, +Input.GetAxis("Vertical"));
if (rb.position.y < -90f)
{
FindObjectOfType<GM>().EndGame();
}
}
}
I tried this but it only rotates the object when i press A or D and doesn’t actually move the object towards the left