Advertisement
S-Hend

SJH Task 3 2025 - Snapzones

May 22nd, 2025
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.41 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class SnapTarget : MonoBehaviour
  6. {
  7.     public Vector3 targetPos;
  8.  
  9.     public int distance;
  10.  
  11.     // Update is called once per frame
  12.     void Update()
  13.     {
  14.         if (Vector3.Distance(targetPos, transform.position) <=distance)
  15.         {
  16.  
  17.             transform.position = targetPos;
  18.                
  19.         }
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement