Search Unity

How to instantiate an object with a one specific rotation from another object

Discussion in 'Scripting' started by zarvin, Jul 30, 2018.

  1. zarvin

    zarvin

    Joined:
    Mar 28, 2017
    Posts:
    14
    Ok so i'm creating a vr game and i'm trying to spawn an object based on the right remotes specific Y axis rotation and 0 for the X and Z axis. Currently i'm doing this,
    Code (csharp):
    1.  
    2. Vector3 pos = new Vector3(RightRemote.transform.position.x, 0, RightRemote.transform.position.z);
    3.             Instantiate(Fissure, pos, RightRemote.transform.rotation);
    4.  
    so basically I want to do this: Instantiate(Fissure, pos, (0, RightRemote Y axis, 0)) IF you know the syntax for this thanks in advance for the help!
     
  2. Doug_B

    Doug_B

    Joined:
    Jun 4, 2017
    Posts:
    1,596
    Something like this maybe? :-
    Instantiate(Fissure, pos, Quaternion.Euler(0, RightRemote.transform.rotation.y, 0))