Home > other >  For help again... How to control an object of the specified axis orientation?
For help again... How to control an object of the specified axis orientation?

Time:09-25

In a 2 d scene,

If (Input. GetMouseButtonUp (0))
{
The transform. LookAt (Input. MousePosition);
}

So only he in front of the shaft will toward the mouse to loosen the point, I want to make the object of the Z axis at the time of the mouse to loosen, loosen the point Z axis toward the mouse, that have a way of operation?

CodePudding user response:

game development can @ I...
I'm not familiar with this

CodePudding user response:

The Z axis is not in front of the shaft? Are you wrong?

If, if you want to make the X axis point to that point, you have to do is go LOOKAT then own Y 90 degrees counterclockwise around objects, that process should be able to imagine
Specific implementation is about 1. LOOKAT (MOUSE) object rotation=quaternion. AixsAngle (90, objects. The transform. The up) * object rotation
Remember to left by is not right

CodePudding user response:

First release the mouse point relative to the direction of the transform and normalize and then directly to the transform of the up, right, forward assignment, specific the three corresponding to the coordinate axis, check the Unity document
  • Related