Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void handleRotation2()
- {
- //Vector3 positionToLookAt;
- Vector2 mouseScreenPosition = playerInput.CharacterControls.MousePosition.ReadValue<Vector2>();
- Vector3 mouseWorldPosition = cam.ScreenToWorldPoint(mouseScreenPosition);
- Vector3 targetDirection = mouseWorldPosition - transform.position;
- Vector3 positionOnViewport = cam.WorldToViewportPoint(transform.position);
- float angle = AngleBetweenTwoPoints(positionOnViewport, targetDirection);
- transform.rotation = Quaternion.Euler(new Vector3(0f, -angle, 0f));
- //float angle = Mathf.Atan2(targetDirection.y, targetDirection.x) * Mathf.Rad2Deg;
- //transform.rotation = Quaternion.Euler(new Vector3(0f, 0f, angle));
- //Debug.Log("MousePos: " + mousePosition.x + " , " + mousePosition.y);
- //positionToLookAt.x = currentMovement.x;
- //positionToLookAt.x = mousePosition.x;
- //positionToLookAt.y = 0.0f;
- //positionToLookAt.z = currentMovement.z;
- //positionToLookAt.z = mousePosition.y;
- //Quaternion currentRotation = transform.rotation;
- //Quaternion targetRotation = Quaternion.LookRotation(targetDirection);
- //transform.rotation = Quaternion.Slerp(currentRotation, targetRotation, rotationFactorPerFrame * Time.deltaTime);
- }
Advertisement
Add Comment
Please, Sign In to add comment