- Home /
 
Move camera forward/backwards with mouse wheel
Hello everyone. I need a script that allows me to move forward and backwards with the mouse wheel. Not zooming in or out, but moving based on the local forward direction of the camera.
Thanks
               Comment
              
 
               
               
               Best Answer 
              
 
              Answer by Thygrrr · May 15 at 04:58 PM
Assuming you use the old InputManager, you can place this on your Camera GameObject to get the desired behaviour.
 using UnityEngine;
 
 public class ScrollWheelMove : MonoBehaviour
 {
     public float speed = 5.0f;
 
     private void Update()
     {
         transform.Translate(Input.mouseScrollDelta.y * speed * transform.forward); 
     }
 }
 
 
              Your answer
 
             Follow this Question
Related Questions
How can I change Z rotation of a FPS player ? 1 Answer
Rigidbody Moveposition not working when Camera follows object? 0 Answers
Camera Relative Movement 2 Answers
First person camera restriction. 1 Answer