Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Need Help: Object Rotation

Discussion in 'Scripting' started by binsint, Jan 27, 2015.

  1. binsint

    binsint

    Joined:
    Jul 16, 2011
    Posts:
    83
    Hi everyone! Im having a problem.. I dont know how to make an child object's rotation become perpendicular to its parent... Ive attached an image to show you my problem.

    as.png

    My obect A is not perpendicular to object B.. My goal is to make my object A rotates so it gets the same result as the RIGHT PICTURE above.. Hope to hear from you.. Thanks!
     
  2. gamer_boy_81

    gamer_boy_81

    Joined:
    Jun 13, 2014
    Posts:
    169
    If you are using the Inspector, then you can just give 90 or 270 in Transform.Rotation component's
    X , Y or Z axis.
     
  3. binsint

    binsint

    Joined:
    Jul 16, 2011
    Posts:
    83
    hi, i want it to be rotated once object A hits object B in runtime.
     
  4. gamer_boy_81

    gamer_boy_81

    Joined:
    Jun 13, 2014
    Posts:
    169
    Ok, can you use transform.Rotate :

    childGameobject.transform.Rotate(0.0f, 0.0f, angle); // angle is in degrees