Rotating GameObject Around Player With "Mouse Y" Position

Good Morning/Afternoon/Evening … Night :slight_smile:

So I’ve currently in the process of scripting out a simplistic game mechanic, whereupon the main player can pick up/throw and rotate the desired gameobject at will. And that’s all going relatively well.

Only I also want the desired Gameobject to be able to rotate around the character depending on where the Mouse cursor is currently centered. So essentially, the Gameobject should seem as if it’s following the Y-Axis (Or camera angle) of the Mouse Cursor, by rotating in an circular arc around the main player.

Many Thanks in advance,
And I do merely apologise if this is a relatively naive question to ask, I’m still in initial learning stages unfortunately. So do know any feedback/criticism or casual insults would be much appreciated :slight_smile:

(Also, If you’re wanting the pickup/throw/rotate code for your own scripts, do merely ask, and I’ll be sure to send it across)

This worked for me for rotating objects on the y axis only. Not sure how to help you on the other parts. Sorry I am new too.

#pragma strict

var damping : int=200;
var target : Transform;

function LateUpdate()
{
   var lookPos = target.position - transform.position;
   lookPos.y = 0;
   var rotation = Quaternion.LookRotation(lookPos);
   transform.rotation = Quaternion.Slerp(transform.rotation, rotation, Time.deltaTime * damping);
}

Something like this

     var multiple : float = 1.0;
    var turnSpeedMultiplier : float = 2.0;
    var turnSpeed : float = 0.0;
    //// in update add following code
    var targetTurnSpeed : float = 0.0;
    targetTurnSpeed= Input.GetAxis("Mouse X");
    targetTurnSpeed *= Mathf.Pow(turnSpeedMultiplier,3);
    targetTurnSpeed *= multiple ;
    turnSpeed = Mathf.Lerp(turnSpeed, targetTurnSpeed, Time.deltaTime * 25.0);
    transform.rotation.eulerAngles.y += turnSpeed * Time.deltaTime;