Player Rigidbody2D未添加力(Unity)

huangapple go评论78阅读模式
英文:

Player Rigidbody2D not adding force(unity)

问题

In the "continue9" function, when using the player's Rigidbody in the last case (case 24), it doesn't add any force to the player.

在"continue9"函数中,在最后一个情况(case 24)中,当使用玩家的Rigidbody时,它不会给玩家添加任何力。

英文:
public void Continue9()
{
    player.dialouge1 = false;
    dialogue = true;
    index += 1;
    switch (index)
    {
        case 21:
            conversation3.SetActive(true);
            text3.text = "No... Not farewell";
            image3.sprite = mirage;
            break;
        case 22:
            text3.text = "Whatcha gonna do now...";
            image3.sprite = scourge;
            break;
        case 23:
            text3.text = "TRANSFORM!!!";
            image3.sprite = mirage;
            break;
        case 24:
            rb.AddForce(Vector2.left * speed1, ForceMode2D.Impulse);
            conversation3.SetActive(false);
            player.Transforming();
            break;
    }
}

In this continue9 function in the last case 24, when I am using the players rigidbody(that has been assigned and is 2D) it doesn't add any sort of force to the player.

答案1

得分: 1

有很多可能性。

  1. 刚体是运动学的。
  2. 该函数从未被调用。
  3. 力的值不足。
  4. 刚体上应用了运动约束。
  5. rb 为空。
英文:

There can be so many possibilities.

  1. The Rigidbody is Kinematic.
  2. The function is never called.
  3. The force value is not enough.
  4. Movement Constraints are applied on the Rigidbody.
  5. rb is null

You will have to debug it one by one. This guide to Unity Rigidbody may be helpful.

huangapple
  • 本文由 发表于 2023年5月30日 06:47:24
  • 转载请务必保留本文链接:https://go.coder-hub.com/76360704.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定