Animation frezzing on first few frames android
Animation just runs the first frame and the game freezes, i dont know what i am doing wrong, it started when i tried to run on another phone's unity remote
using UnityEngine; using System.Collections;
public class Script : MonoBehaviour { public Vector2 speed = new Vector2(100, 100);
// 2 - Store the movement
private Vector2 startPos;
private Vector2 movement;
private Rigidbody2D myRigidBody;
Animator animator;
// Use this for initialization
void Start () {
animator = GetComponent<Animator> ();
myRigidBody = GetComponent<Rigidbody2D>();
}
// Update is called once per frame
void Update () {
if (Input.touchCount > 0) {
Debug.Log (Input.touchCount);
foreach (Touch touch in Input.touches) {
if (touch.phase == TouchPhase.Began && myRigidBody.position.y<=-178.9) {
//animator.SetBool("StartJump",true);
movement = new Vector2 (
speed.x + 40,
speed.y+20);
}
}
}
else {
// 3 - Retrieve axis information
// 4 - Movement per direction
movement = new Vector2 (
speed.x + 30,
0);
}
}
void OnTriggerEnter2D (Collider2D other)
{
if (other.name == "Obstacle") {
Time.timeScale = 0f;
}
else if (other.tag == "coin") {
//Destroy(other);
}
}
void FixedUpdate()
{
// 5 - Move the game object
myRigidBody.velocity = movement;
//Time.timeScale = 0f;
if (myRigidBody.position.y>=-185.9) {
//animator.SetBool("StartJump",false);
}
}
}
You are setting bool StartJump as true on a tap. And each step of physics engine you are setting it to false ins$$anonymous$$d of waiting for animation to play. Can you make a screenshot of your animator and transition conditions?
Your answer
Follow this Question
Related Questions
why does my player move when anywhere on screen is touched? 1 Answer
Player should turn in the direction the player is running. (2D Game) 0 Answers
Help! Values from previous Serialized List<> shows up again after a while using Coroutine 0 Answers
2D Spine Animation not playing 0 Answers
Lighting in my 2D game is slowing it badly on Android mobile 1 Answer