void OnTriggerExit2D(Collider2D other)
{
if (other.tag == "item") { MainSpriteRenderer.sprite = twostep; } if (other.tag == "item") { twostep = Threestages; } if (other.tag == "Enemy") { Threestages = twostep; } if (other.tag == "Enemy") { twostep = onestage; } }
void OnTriggerExit2D(Collider2D other)
{
if (other.tag == "item") { MainSpriteRenderer.sprite = twostep; } if (other.tag == "item") { twostep = Threestages; } if (other.tag == "Enemy") { Threestages = twostep; } if (other.tag == "Enemy") { twostep = onestage; } }
今はif文でPlayerがアイテムや敵に当たれば画像が切り替わるようになっているのですが
3つ目の画像が敵に当たって2つ目の画像になると思ったらいきなり1枚目になったり2枚目の画像を敵に当てても切り替わらなかったりとエラーも吐かれなくて困っています。
調べてみると、if文ばかりは自分も見づらいのでswitch文にしようと思ったのですが
switch ()
{
case 1:
break;
}
と分かるのですが変数の部分がわからず使えません
コードを```c#~```で囲ってほしい
回答1件
あなたの回答
tips
プレビュー