- Home /
Animation issue related to touch input on phone
Hi I'm using this piece of code for animation within my condition : animator.SetInteger("STATE", 1); when I test this on my pc within this code : if(Input.GetMouseButtonDown(0);){ //code } everything is fine but when I test it on my phone the animation wont work unless I hit twice which means I meet the condition twice is there something wrong related to animation when running on phone? because I tested this on many phones it's the same issue but on the PC nothing wrong at all also I used the touch code
if (Input.touchCount > 0) {
if (Input.GetTouch(0).phase == TouchPhase.Began)
{ }
}
the same result any help please?
Are you doing this in FixedUpdate, or Update?
Reading Input in FixedUpdate can cause Input Loss.
is it always twice?
it is in the (update) this is a part of my code: bool $$anonymous$$ouseDown = Input.Get$$anonymous$$ouseButtonDown(0);
if (num_bullet>0)
{
if (corner.transform.eulerAngles.z > 1 && corner.transform.eulerAngles.z < 180)
{
if ($$anonymous$$ouseDown) //$$anonymous$$ouseDown
{
if (num_bullet != 0)
num_bullet -= 1;
if (corner.transform.eulerAngles.z > 1 && corner.transform.eulerAngles.z <= 30)
{
**animator.SetInteger("STATE", 1);**
ShootBullets(bullet, spawnpoint1);
}
the animation part is what having the problems the shooting have no issues and this only happening on the phone on the PC it's totally normal. and Yes it needs to meet the condition twice to set the animation correclty the first shooting wont set the animation to where to should unless I hit again
Have you made 100% Sure the input is not read on the first "Touch" ?
By Debug.Log();
Aside from that, I don't see why the animator should be a problem if the only difference is the Platform.
Here are a few things I found
"animate only if visible was set to true."
What version of Unity are you using? I found this on internet. """ Thank you for taking the time to report this issue. I have been able to reproduce this bug, however it is not reproducible in 5.4, which means that the bug is fixed. If, when that version comes out, you are still able to reproduce it, or have any questions, please contact us again.
Regards, Benediktas Unity QA Team"""
These might be relevant http://answers.unity3d.com/questions/771991/animator-state-not-found-in-ios-build-only.html
http://answers.unity3d.com/questions/1137768/objects-with-looping-animation-disappear-in-ios-bu.html
For the Best!
I have it already and it's even more messed up when I run it on the remote there is no response for the animation at all
What version of Unity are you using? Did You debug Log the state of the Touch input to figure out if first touch works or not.
read this. http://answers.unity3d.com/questions/1143208/objects-with-animationanimator-is-not-showing-up-i.html
Thank you for your advices I used the unity remote along with the debug and I was able to find the issue and I got it sorted thx a lot.
Your answer
Follow this Question
Related Questions
how can create touch screen android scroll in unity3d? 1 Answer
left and right buttons for android 2d game 1 Answer
Can the animation editor create local rotational data? 3 Answers
Something funny that I don't know why 0 Answers
Animator.Update High CPU Usage on Unity 5 resulting in bugs on Android 0 Answers