As you can see in the video, when the mouse goes outside the character still follows while it’s still inside the radius, how can i possibly make an object in Roblox still follow the mouse but it cannot go outside the radius limit?
I’ve successfully made an object follow the mouse, i just need some help on how do i make it still follow the mouse inside the radius limit while the mouse is outside the radius because the object stuck itself in the last position of the mouse when the mouse goes outside the limit
I think I know what you mean, but I’m not certain. It would be helpful if you could include images from your project!
If I understand correctly: Assuming you already have the direction (targetPos - startPos) if you then make it normalized (.Unit) you can multiply it by an integer to set its size. You may also get the length of it by doing .Magnitude.
For example:
local direction = targetPos - startPos
local length = math.min(direction.Magnitude, maxLength) -- Will never be longer than your radius
direction = direction.Unit * length -- Resize it
.Unit normalizes the vector (causes it to have a length of 1), and 1 * length will give the vector a length of length. .Magnitude gets the length of a vector. So, this gives us v.Unit * v.Magnitude = v
I’m interested to hear what other method you used for this! I personally would probably have done it like this, but instead of a UI circle I would have made a circle beneath the character and give it a highlight.