Hey im a Unity and C# beginner, today I started the development of my first ever unity game.
At first you might be like “What problem? I don’t see it!”
well, it’s not a REAL problem but it’s just not what i want but since im a beginner i need a little help on this as i don’t know much about Unity and C# yet, so basically I have a rocket in the game it’s a 3d game and theres a rocket right, i set up controls (WAD) with .AddForce() W to fly, and A and D to go to the sides, the problem is W works perfectly fine but whenever I do A or D it just tilts the rocket to the side and makes it drop, instead, i want it to just shift left and right not tilt left and right. going up is exactly how i want it but i wanna move the rocket left and right so it’s not just like “-tilts- AHHHHHH- (rocket falls to the floor and camera thats attached shakes violently and i can’t get up again)”
I can’t send it for some reason because I don’t know how to but yea hope you understand it also heres the code I used it’s force based
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class FlyingScript : MonoBehaviour
{
public Rigidbody rb;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void FixedUpdate()
{
if (Input.GetKey("w"))
{
rb.AddForce(0, 40, 0 * Time.deltaTime);
}
if (Input.GetKey("a"))
{
rb.AddForce(-4, 0, 0 * Time.deltaTime);
}
if (Input.GetKey("d"))
{
rb.AddForce(4, 0, 0 * Time.deltaTime);
}
}