Launching the ball

For anyone interested , instead of using Invoke () with set amoutn of time, and then tweak it - you can make a pretty fast distance check :
either cheking via easier way:
if(Vector3.Distance(Ball.transform.position,handle.transform.position)< _distance) //detach joint

but if youre keeping optimization in mind , i would suggest not to use Vector3.Distance because it has quit an overhead.Instead you can use .sqrMagnitude with is inbuild in most modern proccessors so it is much faster in executing,so then youll have:
if((currentBallRb.transform.position - handle.position).sqrMagnitude<minDistance*minDistance) //detach the ball

Note taht both those check do teh same ,but getting square of minDistance and sqrMagnitude is much faster then inbuild Vector3.Distance().Hope it will help somebody! =)I cant actually recall what was the problem with teh Invoke method itself, but i guess adjusting the distance feels more accurate then adjusting teh time for me atleast)

2 Likes

Thanks for the suggestion Miagton.

Hope you are enjoying the course :slight_smile:

1 Like

Im totally do! I wish i had this course year ago when i started my unity journey,because most of the local companies are heavy mobile/outsource focused :sweat_smile:

1 Like

Privacy & Terms