I’m creating a drawing line tool, let the lines be the barriers. Everything works as expected. The thing is, if the player moves the mouse too fast, then the drawing function will not be able to update in time to limit the length. I’ve tried multiple ways, but not fixedDeltaTime cause there are other things I want the FIxedUpdate to be normal. So I wanna ask: is there a way to control the length of the lineRenderer that players can not draw the line too long, or must I find another tool to draw those lines? Thank you for your time!
The drawing function should not be responsible for limiting length.
The drawing function should be responsible for visualizing your line data.
Your data flow should be:
- user input
- parse what it means
- if it means “make this line”, then validate length, clamp it, reject it, etc.
- finally update the line endpoints in your data model
Only after that the drawing function can look at your data and update the visible LineRenderer.
Don’t put code in FixedUpdate() unless it is directly related to Physics or Physics2D.
Thank you so much. Then it is the only way to do it. I’ve made it exactly like you said, though, you know, I’m new in both programming and Unity, and I hoped Unity has a way to control it by itself. I didn’t know if I’d done it right or wrong. Once again, I appreciate your time and wisdom!