I am moving an actor based on its relative location from another actor that it is attached to.
I want to restrict movement to not go outside a bounds. For instance, we should not be able to move more than 50cm’s away from the parent in any direction.
The only way I can think to do this is very messy. Something like this:
Get relative location X → if above upper bounds & incoming input is positive, do nothing, only allow negative input
and vice versa for the lower X bounds. And then same thing for upper and lower Y bounds.
This is certainly going to work, but I figured there might be some math trick that might make for cleaner code. Anybody have an idea about something like that?