Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

unity magnetize a 3d object to cursor

mousePosition = Input.mousePosition;
mousePosition.z = Mathf.Abs(cam.position.z - ball.position.z);
mousePosition = Camera.main.ScreenToWorldPoint(mousePosition);
dir = mousePosition - object.position;
ball.AddForce ((dir).normalized * force); 
 
PREVIOUS NEXT
Tagged: #unity #magnetize #object #cursor
ADD COMMENT
Topic
Name
5+5 =