Hi there, Im working on a ipad interface, moving an object via directional buttons. The buttons are working fine but I am at a loss on how to detect which guiTexture has just been released? More to the point is I need to be able to have users be able to hold one button while pressing/releasing the other but not cancel all presses. **think thrust forward (hold button down to thrust) and arc left/right (left right buttons, stop arcing on release)
I am using a series of flags to denote which are being held down, and then applying effect in a separate update. the problems occur on the release of the touch
for (var touch : Touch in Input.touches) {
if(touch.phase == TouchPhase.Stationary){
goingFWD = getGUI.HitTest(Input.mousePosition);
}
}
should I be looping the through the Input.touches on the phase.Ended trigger?
Any direction or advice greatly appreciated, and apologies if this is a newb Q, I did have a look through loads of posts but couldnt find anything that would give me direction.
On the touchscreen devices, the value returned by Input.mousePosition is the position of the first touch (it’s really just a way to make the same code work with desktop and mobile devices in simple cases). To get more than one touch, you will have to use the touch’s position property in place of Input.mousePosition. Also, you will potentially have to check each touch against each button, depending on how your control system works.
Hi again! right Ive got something up and running. I am just checking the approach, I have 4 buttons (GUITextures) on screen (fwd/bck/left/right) the turns are a bit on/off no smooth rotate and the accel/brake is also on/off.
I have a function which is called in the update loop and sets the engine/brake/torque.
Is this the best way of doing this sort of thing?
I have looked at the function of the keyboard input version and noticed that the GetAxis moves between -1 to 1 and is set to 0 when straight
Apologies for the long post and any advice would be excellent
Using integers to denote different control states is generally a pretty good technique since it tends to separate the control input from the code that actually acts on it. With a more complex control system, you might consider using enumerations for the different values but it isn’t necessary or desirable in this case.
Cheers Andeee, yup I’m long term flash programmer so went back to trusted techniques! I am looking into enumerations as at the moment the turns are either on or off no inbetweens (incremented rotations) which you get with the keyboard Axis.