Hi,
We have a character movement interface that includes left/right, jump and dive buttons.
Left and Right have the particularity, that you can slide your finger from one button to the other, and that one becomes 'pressed' which makes the character moved in the desired direction, it's not a slider per se, it's just that without lifting your finger, the button you're on becomes 'pressed'. If you go back to to the previous button now this one becomes 'pressed' again, and the previous one 'unpressed'.
The issue is that when the left/right buttons are pressed, if the Jump or Dive buttons are tapped, even though the movement still works, the buttons show their normal state, i.e. as if they weren't being pressed, but the character does move.
Here's the code:
using UnityEngine;
using System.Collections;
public class InputBtnLeft : MonoBehaviour {
private GameObject btnRight;
void Awake () {
btnRight = GameObject.Find("btnRight");
}
void OnPress (bool pressed) {
if (pressed) {
InputHandler.movingLeft = true;
TouchButtonController.touchBtnLeftPressed = true;
} else {
InputHandler.movingLeft = false;
TouchButtonController.touchBtnLeftPressed = false;
}
}
void OnDragOver(GameObject draggedObject) {
btnRight.SendMessage("OnPress", false);
gameObject.SendMessage("OnPress", true);
}
void OnDragEnd() {
btnRight.SendMessage("OnPress", false);
}
}
The Right button is pretty much the same.
The code inside OnDragEnd is what causes the button to show as unpressed when Jump or Dive are tapped, but I need it so that when the player slides to the other left or right button, it doesn't stay pressed (press here meaning that the character doesn't change direction but keeps moving in the previous direction) as I slide away from it.
We've tried out multiple things found lurking through the forum, but they don't seem to have the same requirements we have.
Is there a way to work around this? Hope you can help out. Is there something like UICamera.hoveredObject but for multitouch? Maybe that is what we need? IDK. Thanks for any help.