Search Unity

Issues instantiating rotated gameobjects

Discussion in '2D' started by Gonzasmpl, Aug 9, 2018.

  1. Gonzasmpl

    Gonzasmpl

    Joined:
    Jul 30, 2018
    Posts:
    55
    Hi!. As said when i use Instantiate(object,position,rotation) in order to create the same object several times at runtime but facing diferent directions. All seems to be working just fine, the sprites and colliders gets rotated, but when a event ocurrs in-game, this gameobjects colliders change bool isTrigger to true as expected, and i want, depending on the direction each one is facing, to do certain things.
    This gameobjects are all the same and thorough a script attached to them when the player touch the collider it starts looking for it´s rotation. The problem is that when i thouch some objects nothing appens.
    I read and conclude that my particular problem is that although i gave them the possibles directions that they can face ( ex.= ...,Quaternion.Euler(180,0,0) ) the real rotation of them is in fact other. I think what happens here is kind of a gimbal lock. Some fix this by changing Quaternion.Euler to Quaternion.AngleAxis but it doesnt work to me. So if someone can help me along with this i will be highly grateful.
    Remember i can only change it´s rotations when they are getting Instantiated