Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- public class MenuParallax : MonoBehaviour
- {
- public float offsetMultiplier = 1f;
- public float smoothTime = .3f;
- private Vector2 startPosition;
- private Vector3 velocity;
- private void Start()
- {
- startPosition = transform.position;
- }
- private void Update()
- {
- Vector2 offset = Camera.main.ScreenToViewportPoint(Input.mousePosition);
- transform.position = Vector3.SmoothDamp(transform.position, startPosition + (offset * offsetMultiplier), ref velocity, smoothTime);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment