martigpg3

Untitled

Aug 16th, 2025
357
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.67 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class ScrollMovement : MonoBehaviour
  6. {
  7.     public GameObject top;
  8.     public GameObject bottom;
  9.  
  10.     public float disntance = 5;
  11.  
  12.     private void FixedUpdate()
  13.     {
  14.         double value = Input.GetAxis("Mouse ScrollWheel");
  15.         Debug.Log(value);
  16.  
  17.         if (value > 0f)
  18.         {
  19.             transform.position = Vector3.MoveTowards(transform.position, top.transform.position, disntance);
  20.         }
  21.  
  22.         if (value < 0f)
  23.         {
  24.             transform.position = Vector3.MoveTowards(transform.position, bottom.transform.position, disntance);
  25.         }
  26.     }
  27. }
  28.  
Advertisement
Add Comment
Please, Sign In to add comment