Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Help with adaptive rotation control w

Discussion in 'Scripting' started by Amuscaria, Jun 16, 2018.

  1. Amuscaria

    Amuscaria

    Joined:
    May 30, 2017
    Posts:
    55
    I'm having trouble with rotating an object based on the camera position. The object rotates along the y-axis, and the x- and z-axes are used for tilting forward/backwards and sideways, respectively. The tilt is controlled by the mouse's X and Y inputs (x for x-tilt, y for z-tilt). The camera orbits round a center point in the scene.

    Since I need to use the mouse to control this, how do I make it so the controls adapt to the camera's rotation so that x- and z-tilts always orient the same way the mouse moves regardless of how the camera faces" (i.g. pulling the mouse down will always tilt the object towards the camera - otherwise the controls flip when the camera is on the other side of the pivot). I have to do this without changing the Y-rotation at all, which has be stomped.

    I'm new to Unity and 3D game making in generate, so I'm not sure what the proper terminology to google, making it difficult to looking up tutorials online. I'm hoping you more seasoned Unity veterans can point me in the right direction or give me some hints. I know it has to do with vector math, but I can't find the proper functions to script with.

    Thanks in advance :)
     
  2. Amuscaria

    Amuscaria

    Joined:
    May 30, 2017
    Posts:
    55
    Nvm, figured it out.