|
Hey Guys, so I'm trying to work with Unity iPhone, i got Unity-Remote so i could test the gameplay on my device. Here is my Project-Overview:
So, the Problem is: i made two scripts for each button with nearly 1:1 code. The Left-Button should move my Playersprite to the left, the Right-Button should move my Playersprite to the right. This is working. My idea is, AFTER i press one of the buttons, the Character starts to move AND the animation is played. I'm trying to work with the Touch-Phases, but i don't get a solution i am satisfied with, because sometimes, my device doesn't recognize a certain phase. When i press the button it's moving all along, that's fine (although, the animation is stuck in the first frame and plays the whole animation after releasing my finger from the screen <- how can i solve this "Sideproblem"). When i release my finger, it sometimes doesn't recognize the Touch-Phase has ended. I made some Debug.Logs to figure out when something happens. I am sitting three days for now in front of this problem, looked up the internet, tried some other "solutions" in order to get nice touch-handling but nothing worked properly, it's devastating, so i beg you, could someone please help? Of course here is my code so far:
(comments are locked)
|
|
It looks like playingAnim = false; Should be positioned after the condition that checks if it is false. if(playingAnim == false) { ... } playingAnim = false; That should allow you to stop the animation... the side problem. For the main issue, could it be that your code is misinterpreting the canceled phase as a begin phase? http://unity3d.com/support/documentation/ScriptReference/TouchPhase.html You might be able to confirm if you explicitly handle each touch phase possibility, there are 5, and print a debug log statement for each distinct phase.
(comments are locked)
|

Did you ever get a satisfactory solution to this issue? I've been having a very similar problem for a while now and it is killing my project.
Well I can tell you that I had to write my own wrapper that sorted out whether a touch phase had ended or begun because I couldn't get the right values. A missing touch fires a cancelled event for me etc.