My rocket is not flying



I myself modeled a rocket in the 3d max program. when i try to fly it it doesn’t fly. but when i put a box it flies. I did everything the same on both. In the second picture, the box has flown and is not visible, but the rocket I modeled falls to the ground. Why doesn’t my own modeled rocket fly?

{
    rb = GetComponent<Rigidbody>();
}

// Update is called once per frame
void Update()
{
    ProcessUcma();
    ProcessDonme();
}

void ProcessUcma()
{
    if (Input.GetKey(KeyCode.Space))
    {
        rb.AddRelativeForce(Vector3.up);
    }

}
   void ProcessDonme()
    {
        if (Input.GetKey(KeyCode.A))
        {
            Debug.Log("Sola Dönüş");
        }

        else if (Input.GetKey(KeyCode.D))
        {
            Debug.Log("Sağa Dönüş");
        }
    }
}

I assume you attached the movement script to your modeled rocket, right? If you had the Debug.Log statement for KeyCode.Space, does it print to console that you pressed space?

The only other thing I can think of is that maybe your rocket is too heavy? Did you try reducing the mass further to see if the rocket moves. Additionally you could also create and initialize a new variable to boost the thrust output; multiply the (Vector3.up) with your new variable to see if you can get the rocket going.

Thank you for your reply but I tried many things but it doesn’t fly. I increased or decreased the rigidbody’s strength, it still didn’t fly. stays in place. I threw a mesh collider into my own rocket. I don’t know if there is a problem with this. I just realized this. I locked some positions. It is going at a very good speed in the x direction, but not in the up direction. It just doesn’t go up.

Can you show the rocket’s values in the inspector? You showed both together, but I would like to see the rocket by itself.

the values ​​of this my rocket.

I think If you unlock the z-axis position it should fly.

You have applied rotations to the model, so your rocket’s z is now pointing up (or down). If you click here
image

and change it to ‘Local’ you should see that.

But, you don’t necessarily want to unlock the axis. What you want to do is rotate the model without affecting the rotation. To do that, you need to remove the rocket’s visual (model) from the game object, and make it a child of the rocket.

Simple way:

  • Create a new Game Object and call it ‘Rocket’. Make sure there is no rotation on it.
  • Drag your model onto this game object in the hierarchy. You want something like
Scene
  |- Rocket
    |- Model
  • Rotate only the model the way you want it. The rocket must still have 0 rotation
  • Add a rigidbody to the rocket, not the model
  • Add a collider to the rocket, not the model
    • Adjust the collider to match the rocket
  • Add your movement script to the rocket, not the model
  • Try again

Another way:

  • Remove these two components (MeshFilter and MeshRenderer)
    image
  • Reset the transform’s rotation
  • Drag your model onto this game object in the hierarchy. You want something like
Scene
  |- Rocket
    |- Model
  • Rotate only the model the way you want it. The rocket must still have 0 rotation
  • Try again

thank you very much. you are really professional. Now my rocket is flying. thank you for your help :blush: :smiling_face_with_three_hearts:

My rocket is flying now. I was glad for that, but early. :sweat_smile:. now it doesn’t go left and right when flying :pensive: . what should i do?

Can you show the movement code?

{

[SerializeField] float itmehizi = 100f;
[SerializeField] float donmehizi = 100f;
Rigidbody rb;
AudioSource ses;
// Start is called before the first frame update
void Start()
{
    rb = GetComponent<Rigidbody>();
    ses = GetComponent<AudioSource>();
}

// Update is called once per frame
void Update()
{
    ProcessUcma();
    ProcessDonme();
}

void ProcessUcma()
{
    if (Input.GetKey(KeyCode.Space))
    {
        rb.AddRelativeForce(Vector3.up * itmehizi * Time.deltaTime);
        if (!ses.isPlaying)//eğer spaceye basıldığında ses çalmıyosa sesi çal
        {
            ses.Play();
        }
    }
    else //değilse çalma
        {
        ses.Stop();
    }


}
   void ProcessDonme()
    {
        if (Input.GetKey(KeyCode.D))
    {
        donus(-donmehizi);
    }

    else if (Input.GetKey(KeyCode.A))
        {
        donus(donmehizi);
        }
    }

void donus(float DonBuFrame)
{
    rb.freezeRotation = true; //burada dönmeyi dondurduk
    transform.Rotate(Vector3.forward * DonBuFrame * Time.deltaTime);//buradaki forward (0,0,1(z)) görevi görüyor.
    rb.freezeRotation = false; //burada dönmeyi tekrar açtık
}

}

Looks fine, can you show the rocket after the above changes?

can you connect to my screen with teamviewer? you can solve the problem by yourself :blush:

No, I’m not going to do that. You could upload your project somewhere and I can look at it

ok now i will upload a video on youtube

Upload the Unity project. Not a video. Zip it up and put it somewhere that I can download it and open

https://dosya.co/s316anj3dysw/mygame.rar.html

You have an error in the console. You did not attach an AudioSource to the rocket. Once you do that, the rocket will turn

Finally happened. You tried so hard to solve this. thank you very much :relaxed:

Hi @hamza99,

Welcome to our community! :slight_smile:

I’m glad to see that bixarrio was able to help you. Is the problem solved?


See also:

yes, problem solved. thank you very much. I’m very new to learning unity. If I have any new questions, I will ask again. :blush: :blush:

Privacy & Terms