Hi, I am trying to control my character using an onscreen touch joystick. I have written this code with OnPointerDown, OnPointerUp and OnDrag and it works perfectly. The issue I am having is that this does not really replicate a real controller in the sense that if you keep the joystick pressed in a direction on a controller the movement in that direction continues. In my case if you keep the joystick pressed in a direction than it does not generate another event for movement unless i make a change in the direction axis. Is there an event or something i do not know about to do this? I have looked over the unity documentation and google searches but did not find anything usefull on what I am trying to achieve here. Note that this will be an optimised mobile game so I do not want to use fixed update or just update. Any help is apreciated. Thank you!
Update:
Added code:
public void OnDrag(PointerEventData ped)
{
//move joystick
//move character
}
public void OnPointerDown(PointerEventData ped)
{
OnDrag(ped);
}
public void OnPointerUp(PointerEventData ped)
{
//reset joystick
}
I had not added more code as it would not be relevant to my current problem.
I am moving the character about a unit in the direction of the joystick on each dragging move.
The issue i am facing is that OnDrag really works only on drag and i was wondering if there is some way to make it fire events like let’s say every 0.5 s while the joystick button is being hold down. At first when writing this code I had asumed that the OnPointerDown does just that … while it is being hold down would fire events but that is really not the case.