// Use this for initialization void Start() { detect = GetComponent <HumanDetectAnimeState>(); cur_anime_state = detect.state; gender = GetComponent <HumanGender>(); SetLive2D(); }
// Update is called once per frame void Update() { if (agent.velocity.magnitude <= stop_velocity) { state = HumanAnimeState.Stand; } else if (agent.velocity.x < 0) { state = HumanAnimeState.Left; } else { state = HumanAnimeState.Right; } //Debug.Log(state); }
// Update is called once per frame void Update() { if (detect.state != cur_anime_state) { cur_anime_state = detect.state; timer = 0.0f; if (cur_anime_state == HumanAnimeState.Stand) { spriteRenderer.sprite = GetProperSprite(0); spriteRenderer.flipX = false; } else if (cur_anime_state == HumanAnimeState.Left) { spriteRenderer.sprite = GetProperSprite(1); spriteRenderer.flipX = true; } else { spriteRenderer.sprite = GetProperSprite(1); spriteRenderer.flipX = false; } } else { if (cur_anime_state != HumanAnimeState.Stand) { timer += Time.deltaTime; if (0 <= timer && timer < animeDuration * 0.5f) { spriteRenderer.sprite = GetProperSprite(1); } else if (animeDuration * 0.5f <= timer && timer < animeDuration) { spriteRenderer.sprite = GetProperSprite(2); } else { timer = 0.0f; } } } }
void SetAnimation() { if (State == HumanAnimeState.Stand) { old_state = HumanAnimeState.Stand; body_sprite_render.sprite = walk_animes[0]; } else if (old_state != HumanAnimeState.Left && State == HumanAnimeState.Left) { anime_timer = 0.0f; old_state = HumanAnimeState.Left; body_sprite_render.sprite = walk_animes[1]; } else if (old_state != HumanAnimeState.Right && State == HumanAnimeState.Right) { anime_timer = 0.0f; old_state = HumanAnimeState.Right; body_sprite_render.sprite = walk_animes[2]; } }
// Update is called once per frame void Update() { Vector3 velocity = transform.position - old_pos; old_pos = transform.position; if (velocity.magnitude <= STOP_VELOCITY_X) { State = HumanAnimeState.Stand; } else if (velocity.x < 0) { State = HumanAnimeState.Left; } else { State = HumanAnimeState.Right; } //Debug.Log(State); SetAnimation(); }