I would like to do the limitation based on the localPosition. I have tried to clamp the position, but after I rotate the object the axis are not correct anymore and it doesn’t work.
Ah, sorry My goal is to limit the object movement in one axis. I have a parent object, let’s call it a PivotPoint and a child object Cue (billiard cue). I rotate the object around the pivot point and that works ok. Also the movement towards the pivot point works ok. But I want to limit the movement so it doesn’t go through the pivot point and no further than 0.5f in another direction.
Thank you! I got it to work now. Your example worked fine, but I didn’t figure out how to clamp the position to the other direction. I tried this way, but when moving fast it started to bug because it went “through” the zero point and the magnitude started to increase again.