Gravity Gun Script -
[Header("Settings")] public float grabRange = 5f; public float throwForce = 15f; public float holdDistance = 2f; public float pullForce = 10f; public float rotationSpeed = 100f;
void PullObject() { RaycastHit hit; Ray ray = playerCamera.ScreenPointToRay(new Vector3(Screen.width / 2, Screen.height / 2, 0)); Gravity gun script
if (isHolding && heldObject != null) { // Move held object to hold point Vector3 targetPos = holdPoint.position; heldObject.velocity = (targetPos - heldObject.position) * pullForce; [Header("Settings")] public float grabRange = 5f
using UnityEngine; public class GravityGun : MonoBehaviour { [Header("References")] public Camera playerCamera; public Transform holdPoint; public LayerMask grabbableLayer; public float throwForce = 15f