How to zoom with mouse wheel?

Hello, I need some help on the following code: :face_holding_back_tears:

CameraMovement.prototype.onMouseWheel = function (event) {

    this.entity.translate (0,0, event.wheel * 10);

The camera is attached to a camera axis, under an entity that contains a walking avatar. Can I set the camera position or translate it to adjust the distance between the avatar and camera?

Thank you so much! :pray:t2:

Hi @ntleung and welcome,

You can check mouse wheel zoom works in the orbit camera example. Here is the example:

And here is the script code:

1 Like

In your case, changing translate to translateLocal may be enough for you so that you move the camera along the local Z axis rather than the world

1 Like

Thanks a lot for the help! Will try the above solutions :pray:t2: :raised_hands:t2: