Hello all and Merry Christmas!! I have a raycast problem I need help with.

I’m trying to call up a simple tween animation when I click onto my specific object. The iTween Part is easy, I’ve got that one down. My problem is, that I need to have this active only at a certain distance. I need for this little animation to happen only when I click on the object “from up close.” As it is, I can click on the object at any distance and the tween activates which isn’t going to work. Can you help me?

Happy New Years!!

do a Vector3.Distance between you and the object. if youre within the distance you want play the animation.

So How would I write that out to identify my situation?
~K

First, use Vector3.Distance() to compute the distance to the object of interest. Then, write an ‘if’ statement, and for the conditional, compare the distance (using less-than or less-than-or-equals-to comparison) to whatever you want the distance threshold to be. Finally, in the body of code associated with the ‘if’ statement (that is, the code in curly brackets following the ‘if’ statement), do whatever you want to do if the object is close enough.

That should give you enough info to give it a go yourself. If you run into problems of find it’s not working, post your code here so we can take a look.

Thanks a lot that should get me started Jesse!
~K