Holder contains camera and rotates around player

Camera looks like in diablo, titan quest, grim dawn, etc

I cant rotate camera to negative angle values

My code:

public void ChangeRotation(float val){
    isTurning = true;
    needAngleY += val;

void Turning(){
    Quaternion quatertion = transform.rotation;
    Vector3 eulerAngle = new Vector3(0, quatertion.eulerAngles.y, 0);

    if(needAngleY - eulerAngle.y < 0.2f){
        if(needAngleY == 360 || needAngleY == -360){
            needAngleY = 0;
        eulerAngle.y = needAngleY;
        isTurning = false;
    } else {
        eulerAngle.y = Mathf.Lerp(eulerAngle.y, needAngleY, timeRotation * Time.deltaTime);
    m_Compas.rotation = eulerAngle.y;
    quatertion.eulerAngles = eulerAngle;
    parentTran.rotation = quatertion;

You can use transform.RotateAround() to specify a rotation axis for your camera. If you pass in the player transform.position as the first param and the axis you want to rotate around as the second, this should get you what you want.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .