- Home /
iam using a button for moving my player but it move by clicking one time only where if i hold the button player doesnt move until i click again?,i use button for my player to move but it moves on one click
i make a button where if i press it , it calls a function that move my player on x-axis , but when i click button my player move a bit and stop , that because the function is called on one click where if i hold the button my player doesnt move is their a clear code for solving this problem ? @Zephire ,i make button which when pressed a function is called where player moves on x-axis but my player is moving only by one click where if hold down the button my player doesnt move
Answer by Geejayz · Jul 31, 2018 at 01:37 PM
Hi, It sounds like you are using Input.GetMouseButtonDown Try using Input.GetMouseButton.
GetMouseButtonDown will only execute once until you release it and push the button again, GetMouseButton will execute with each frame as long as the button is being held down.
Hope this resolves for you.