Showroom camera - mouse centering problem

I am trying to create a rotation system around my object so that when i hold down left mouse button and move the mouse, the camera rotates round the character and when you let go of it, the view stays where it is. Once you let go, you can use the custom mouse pointer to click on items in the scene.

I have the problem that when you rotate the camera, the pointer snaps to the center of the screen (when i want it to stay in place) and jolts the camera. I am aiming for a way to have a similar system to the game World of Tank/Tank Force for reference. Any idea of how i could achieve this?

One way to achieve this is to parent your camera to an empty, which carries the Mouse Look Actuator.
Here is a minimal example:

If you move the mouse in x-direction (which is the left-to-right direction), the empty will rotate around it’s z-Axis.
Make sure you uncheck “Reset”, because this will shift the mouse cursor to the center of the screen.

omg thx :slight_smile:

Dude just fake it ,Use a cube and lock a particular rotation on a certain axis. Then u should be fine LoL.
Or apply both transform Locks on both axis.



how to make the camera, after clicking the left mouse button, fast moving and releasing this button, the camera continued to move in the right direction, but gently slowing down to zero. Just like on the sketchfab page, how do you want to view a 3d object

you could just use logic bricks to switch between a fast mouselook actuator and a slow actuator. then slow parent camera 10 or 15.

otherwise you need python.

Unfortunately, I did not find any script in python that would match what I want to get, but I found a script in C # for Unity3D. The question is whether this script can be “converted” to python, or Unity uses some magical functions that BGE python Api does not have??

using UnityEngine;
using System.Collections;
#region Delegates
public class CameraController : MonoBehaviour {

    #region Private References      
    [SerializeField, Range(0.0f, 1.0f)]
    private float _lerpRate;
    private float _xRotation;
    private float _yYRotation;


    #region Private Methods
    private void Rotate(float xMovement, float yMovement)
        _xRotation += xMovement;
        _yYRotation += yMovement;

    #region Unity CallBacks
    void Start ()
        InputManager.MouseMoved += Rotate;
    void Update ()
        _xRotation = Mathf.Lerp(_xRotation, 0, _lerpRate);
        _yYRotation = Mathf.Lerp(_yYRotation, 0, _lerpRate);
        transform.eulerAngles += new Vector3(0, _xRotation, -_yYRotation);


   void OnDestroy()
       InputManager.MouseMoved += Rotate;    

or another script with zoom :

using UnityEngine;
using System.Collections;
[AddComponentMenu("Camera-Control/Mouse Orbit with zoom")]
public class MouseOrbitImproved : MonoBehaviour {
    public Transform target;
    public float distance = 5.0f;
    public float xSpeed = 120.0f;
    public float ySpeed = 120.0f;
    public float yMinLimit = -20f;
    public float yMaxLimit = 80f;
    public float distanceMin = .5f;
    public float distanceMax = 15f;
    private Rigidbody rigidbody;
    float x = 0.0f;
    float y = 0.0f;
    // Use this for initialization
    void Start () 
        Vector3 angles = transform.eulerAngles;
        x = angles.y;
        y = angles.x;
        rigidbody = GetComponent<Rigidbody>();
        // Make the rigid body not change rotation
        if (rigidbody != null)
            rigidbody.freezeRotation = true;
    void LateUpdate () 
        if (target) 
            x += Input.GetAxis("Mouse X") * xSpeed * distance * 0.02f;
            y -= Input.GetAxis("Mouse Y") * ySpeed * 0.02f;
            y = ClampAngle(y, yMinLimit, yMaxLimit);
            Quaternion rotation = Quaternion.Euler(y, x, 0);
            distance = Mathf.Clamp(distance - Input.GetAxis("Mouse ScrollWheel")*5, distanceMin, distanceMax);
            RaycastHit hit;
            if (Physics.Linecast (target.position, transform.position, out hit)) 
                distance -=  hit.distance;
            Vector3 negDistance = new Vector3(0.0f, 0.0f, -distance);
            Vector3 position = rotation * negDistance + target.position;
            transform.rotation = rotation;
            transform.position = position;
    public static float ClampAngle(float angle, float min, float max)
        if (angle < -360F)
            angle += 360F;
        if (angle > 360F)
            angle -= 360F;
        return Mathf.Clamp(angle, min, max);

i tested something similar, her is the blend for you to check out, maybe you could fine something useful in it.

Press R Mouse Button to rotate Camera
Click L Mouse Button on ground to move around
Scroll wheel to zoom

This is not the point … simply rotate the camera around the object, and stop it immediately when you release the right mouse button that I can do. I need the camera to release the right mouse button gently and continue the movement to stop

i have updated the blend to include lag when rotating the camera.

(download it from post #8)