How to set Max and Min distance on AddLocalOffset?

I currently have a sphere on my third person character that Im using as a curser of sorts. When you move your mouse up and down the sphere should get closer and father from you, but only to a minimum and maximum distance (right now if you keep moving your mouse up the ball will go away from you forever). I’ve tried using clamp but it seems to only allow the curser to move away from my character and not back.

Hey @drover15

AddLocalOffset uses a Delta input, so which value should be added to the current position to create an offset.

Your value comes from MouseY. Whenever you move your mouse you create a value between -1 to 1. Even if you clamp this value you still get a value between e.g. 0-0.5.

If you want to ristrict the movement you can do something like:

Did I do something wrong here? I’ve replicated the blueprint but now the curser isnt moving. I had to assume Min X and Max X are variable floats, and I set min to 0 and max to 60.

Hey @drover15

could you show your blueprint or say how it is set up. My example gives you the offset when Actor Origin and Scene Component Origin are equal. If they are at like 0,0,0 and 120,0,0 from the start and you set your Max to 60 you are above the Max from the start.

Try this

The error is that you using Local Offset, but using world locations.
Remove Get Actor Loc and [-] node, replace Get World Loc with Get Relative Loc.

Thanks for the help, it worked partly, once reaching the min and max value the code would stop working. I ended up figure it out and making it work, but in the end the feeling of the mechanic was too janky, im looking at an alternate solution using Line Plane Intersect

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.