Skip to content

Lecture14のレーザーの当たり判定 #19

Description

@Bunny63857

#問題
Laserクラスの衝突判定部分について
現状だとparallelVectorの値が正でも負でも当たり判定をしてしまうため、プレイヤーがレーザーの後ろに回り込んだ場合も当たり判定をしてしまう。

#解決方法
内積からプレイヤーとレーザーの位置関係を判定して、正の場合のみ当たり判定を行うようにする
float hantei = asd.Vector2DF.Dot(destDirection, direction);
if (hantei>0){
player.OnCollide(null);
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions