Greetings, I’ve been searching throughout most of the google to try finding the solution to this and it seems like there isn’t any kind of help to my problem. The only thing I need is how to get the direction towards the player is facing and implementing the rotations. The intentions with this are, when the player moves the mouse vertically/horizontally while on rotation mode, the object will rotate forwards/sidewards, so the player can manipulate the grabbed object with much more efficiency.
Here’s an example image that may help you understand my problem:
Here’s my shot at it:
private void Update()
{
Horizontal = Input.GetAxis("Mouse X");
Vertical = Input.GetAxis("Mouse Y");
}
private void FixedUpdate()
{
//**ROTATE OBJECT**
if (isRotate)
{
var step = rotatingSpeed * Time.deltaTime;
if(Horizontal != 0f || Vertical != 0f)
{
var direction = (Vector3.forward * Horizontal) + (Vector3.right * Vertical);
direction.Normalize();
if(Horizontal != 0 || Vertical != 0)
{
grabbedObject.transform.Rotate(direction * step);
}
}
}
}
Thanks in advance! ![]()
