Search Unity

  1. Unity 2018.3 is now released.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Want more efficiency in your development work? Sign up to receive weekly tech and creative know-how from Unity experts.
    Dismiss Notice
  4. Build games and experiences that can load instantly and without install. Explore the Project Tiny Preview today!
    Dismiss Notice
  5. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  6. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice

ARCore 1.4.1 Align rectangle pararell to floor

Discussion in 'ARCore' started by daw_it, Sep 3, 2018.

  1. daw_it

    daw_it

    Joined:
    Sep 3, 2018
    Posts:
    3
    How can I set rotation of the placed on vertical plane object to make its bottom side pararell to floor? At the moment vertically placed objects are sticky to the wall but have random rotation. I have been trying to set object on horizontal plane and then adjust vetical objects vector forward to horizontal objects vector up. That seems to work somehow but multiple objects apart of being pararell to each other are rotated in christmas tree shape. Important thing - I want to rotate it relative to real world, not to bottom of the screen.

    Code (CSharp):
    1. VerticallyPlacedObject.transform.forward = HorizontallyPlacedObject.transform.up;
    What I want:


    What I get:
     
    Last edited: Sep 3, 2018
  2. tdmowrer

    tdmowrer

    Unity Technologies

    Joined:
    Apr 21, 2017
    Posts:
    268
    The basis you drew in "What I want" implies a right handed coordinate system, while Unity uses a left handed one, so you can't achieve a transform like that. If you flip one of the vectors (eg, make "forward" point away from the floor rather than towards it), then that is possible.

    You might be looking for Quaternion.LookRotation, which takes a forward and an up. Forward in this case might point away from the floor and "up" would be the plane's normal. That would give you what you describe, if I understand your intent correctly.
     
  3. daw_it

    daw_it

    Joined:
    Sep 3, 2018
    Posts:
    3
    I am placing rectangular shape object. I would like to that object bottom side perpendicular to floor. Way that You pointed didn't work. Perhaps there is way to do it without placing another object on floor at the very begining?
     
  4. tdmowrer

    tdmowrer

    Unity Technologies

    Joined:
    Apr 21, 2017
    Posts:
    268
    Could you be more specific? What was the result? Could you post some code?

    You should not need to first place an object on the floor. Here's what I was thinking:

    Code (CSharp):
    1. var placedObjectForward = Vector3.up;
    2. var placedObjectUp = normalToPlane;
    3. VerticallyPlacedObject.transform.rotation = Quaternion.LookRotation(placedObjectForward, placedObjectUp);
     
  5. daw_it

    daw_it

    Joined:
    Sep 3, 2018
    Posts:
    3
    Thanks, it worked.