Search Unity

Respawn - Not rotating prefab

Discussion in 'Scripting' started by matikajnen, Dec 30, 2020.

  1. matikajnen

    matikajnen

    Joined:
    Nov 28, 2020
    Posts:
    2
    Hello,
    I have an issue. I want to respawn prefab and moving around in nav mesh. Nav mesh is working when it respawn prefab but prefab rotation is wrong and it seems like it is moving in head/butt. I tried everything to fix it but nothing worked, so if someone help me i would be very happy :)

    Most important piece of code:
    void Start()

    {
    InvokeRepeating("reSpawn", 20f, repeatTime);
    }

    private void reSpawn(){
    //Instantiate(spider, spawn.position, Quaternion.Euler(90, 0, 0));

    Instantiate(spider, spawn.position, spawn.rotation * Quaternion.Euler(90, 0, 0));
    }

    In game it seems like and spawn point or prefab initial settings are:
    https://ibb.co/NYmzTLL

    When i start game prefab armatures rotation on X = -89.xx and even i change function to 0 its always set as on picture. I also tried: gameobject obj = Instatiate(spider, spawn.pos, spawn.rot).as gameobject
    obj.transform.rotate(90,0,0) but it has no effect.

    For every tips thanks.
     
  2. matikajnen

    matikajnen

    Joined:
    Nov 28, 2020
    Posts:
    2
    Finnaly fixed. Solution: Armature od that prefab was in -90 degrees so i changed that and now it working properly