アニメからアニメへ遅延ゼロで切り替えたいです。
横スクロールにしゃがみを実装したく、アニメを作ったのですが
Has exit time のチェックを外したり、transitionを0にしたり
してみましたが、それでも若干遅延してしまいます。
ボタンをちょい押しするくらいなら全然問題ないのですが、
長押ししたあとにボタンを離すと「離すと同時に」ではなく
「離した後に」立ち上がるような感じで、若干遅れてしまいます。
スパッと切り替わる方法をご存知の方がいらっしゃいましたら、
どうかご教示お願いいたします。
プレイヤーのソースコードも一応貼ります。
該当のソースコード
using System.Collections; using System.Collections.Generic; using UnityEngine; public class player : MonoBehaviour { private Animator anim; public float Lowspeed = 0; public float speed = 10; public float MAXspeed = 25; public float key = 0; private Rigidbody2D rb; private SpriteRenderer sp; // Start is called before the first frame update void Start() { this.anim = GetComponent<Animator>(); this.rb = GetComponent<Rigidbody2D>(); this.sp = GetComponent<SpriteRenderer>(); } // Update is called once per frame void Update() { //keyを代入 float x = Input.GetAxisRaw("Horizontal"); float vertical = Input.GetAxis("Vertical"); //しゃがみ if (vertical < 0) { speed = 0; anim.SetBool("crouch", true); } else { anim.SetBool("crouch", false); } //入力がない時は0になるようにする anim.SetFloat("Speed", Mathf.Abs(x * speed)); //スプライトのむきを変える if (x < 0) { sp.flipX = true; if ( key == 1) { key = 0; } else { key = -1; } } else if (x > 0){ sp.flipX = false; if (key == -1) { key = 0; } else { key = 1; } } //xが0の時、speedの数値を下げる if ( x == 0 & speed >Lowspeed) { speed -= 1 ; } if (x != 0 & speed < MAXspeed) { speed += 0.8f; }else if (x != 0 & speed > MAXspeed) { speed = MAXspeed; //speedがMAXを超えた時、25固定にする } //左右へ移動 if(vertical != -1) { rb.AddForce(Vector2.right * x * speed); } } }
試したこと
has exit timeのチェックを外す
transitionを0にする

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2021/08/17 14:46
2021/08/17 14:52
2021/08/17 15:22