- Home /
Question by
qasem-salehy · Jul 30, 2019 at 07:52 PM ·
touchrotate objectmouse-drag
face gameobject to mouse (touch) drag direction
hi i have a game object in my scene i want to rotate it to up if i moving my finger (or mouse) to up if i drag to left i want my game object face left
<< i have a image to explain better >>
sorry for my bad english
(i want to create a controll like flaming core game)
untitled.png
(10.3 kB)
Comment
Answer by xxmariofer · Jul 30, 2019 at 09:54 PM
Vector3 startPos;
Vector3 endPos;
void OnMouseDown()
{
startPos = Input.mousePosition;
}
void OnMouseUp()
{
endPos= Input.mousePosition;
transform.forward = endPos - startPos;
}
it works but i what to "rotate" game object to mouse direction
look :
it facing down when i drag down but it should be like that :
can you see the different ? it should rotate in y and point to mouse location :D sorry for my bad english again :p
untitled.png
(66.7 kB)
2.png
(67.5 kB)