Instantiated object x and z rotation set to zero

I have a enemy called crystal enemy, which if close enough, looks at the player and instantiates a fireball. But the problem is the x and z rotation of the fireball is wrong, so it only shoots straight, but doesn’t shoot up and down for some reason. My shoot function is like this(Inside the enemy):

public void ShootFireball()
    {
        StartCoroutine(ShootDelay(ShootingDelay));
        GameObject InstantiatedFireball = Instantiate(Fireball, FireballShootPoint.position, transform.rotation);
        InstantiatedFireball.GetComponent<Fireball>().EnemyShot = true;
        InstantiatedFireball.GetComponent<Fireball>().Damage = EnemyDamage;
    }

My fireball function is like this(inside the fireball prefab):

private void Start()
    {
        rb = GetComponent<Rigidbody>();
        rb.velocity = transform.forward * Speed;
        Destroy(gameObject, Lifetime);
    }

I have also tried setting the rotation after the instantiaion, but it didn’t work either. My player has a instantiate fireball script as well when clicking, and that works just fine, even though it is basically the same thing

The fireball’s forward and up axis should be the same as the enemy’s and ideally both should be orientated so that they’re looking along their forward axis. If their models are pointing in the wrong direction then you can reorientate them in a modeling app like Blender.

Another possibility is that the fireball is overlapping the enemy when you instantiate it and this is interfering with its orientation.

1 Like

Sorry for the very late reply.

My problem is not the model facing the wrong direction, my problem is that the fireball is not moving in the right direction. And in my code, it should be moving in the direction it is rotated to, but when I instantiate it, the x and z rotation is automatically set to 0. Even after instantiating it if I set the rotation, it still doesn’t work. I also have tried removing the script, and only instantiate the object without any extra components, but it still instantiates it with 0 as the x and z.

I finally found why it is happening. It is happening because of the navmesh. I tried disabling the navemsh before shooting the object and then enabling it again. It didn’t work at first, as it seems like there is some kind of delay to disabling and enabling a component. I was able to make it work with some very sketchy code. Now it does work, but I would love to hear about a way to do this without enabling and disabling the navmesh, which I don’t think is a very good way to go about this.