Instantiate a GameObject with a specific Z rotation

Hi there ! First, sorry for the english mistakes I’m not from England or wathever. Here is my problem : I’m making a demake (NES style) of Portal from Valve and my problem is when I create a portal. When I’m instantiate it, the portal will appear in his origin rotation. I tried to impose a specific Z rotation to the portal but it will always appear with the same Z rotation. What I want is when the portal appears on a wall the portal is vertical and when the portal appears on a ceiling it is horizontal. I saw on Internet to use Quaternion but I don’t understand it… I put some screenshots of the game and the portal’s script for you to understand my problem better. Thanks to the poeple who will help me :slight_smile:

Game view > game hosted at ImgBB — ImgBB
Script > script hosted at ImgBB — ImgBB

I suggest using a raycast to check if the surface is a WALL or CEILING, Then Change the rotation of the portal according to that

To set a specific rotation (while instantiating the portal) use “Instantiate
And to check the type of surface use “raycasting

you can use qaternion.AngleAxis
its a quaterion unit, but you can set it as a axis rotation, easy to understand

on the quaterion section, you can declarate a qaternion.angleaxis and set the z value