I realize that player still move to weapon location after picking it with mouse, even though in PlayerController class, update method is return after InteractWithComponent run. Is there a way to fix it?
The trouble is that unless you click really really really fast, the mouse button will still be down on the next frame. Since the movement routine uses Input.GetMouseButton() instead of Input.GetMouseButtonDown(), this will naturally cause us to move on the next frame…
There are a couple of solutions:
- You could change the movement code to test for Input.GetMouseButtonDown. This would eliminate continuous update of movement coordinates.
- You could set a boolean “itemclicked” when the pickup is clicked on, and only reset itemclicked on an Input.MouseButtonUp.
if(!itemClicked) InteractWithMovement();
This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.