Fixed collision detection bug

This commit is contained in:
JappaWakka 2022-10-13 13:26:01 +02:00
parent 7ca13b1a8d
commit 169ce4c709
1 changed files with 5 additions and 5 deletions

View File

@ -797,7 +797,7 @@ Public Class OverworldCamera
Public Function CheckCollision(ByVal newPosition As Vector3) As Boolean Public Function CheckCollision(ByVal newPosition As Vector3) As Boolean
Dim cannotWalk As Boolean = True Dim cannotWalk As Boolean = True
Dim setSurfFalse As Boolean = False Dim setSurfFalse As Boolean = False
Dim Position2D As Vector3 = New Vector3(newPosition.X, newPosition.Y - 0.1F, newPosition.Z) Dim Position2D As Vector3 = New Vector3(newPosition.X, CSng(Math.Floor(newPosition.Y)), newPosition.Z)
For Each Floor As Entity In Screen.Level.Floors For Each Floor As Entity In Screen.Level.Floors
If Floor.boundingBox.Contains(Position2D) = ContainmentType.Contains Then If Floor.boundingBox.Contains(Position2D) = ContainmentType.Contains Then
cannotWalk = False cannotWalk = False
@ -807,7 +807,7 @@ Public Class OverworldCamera
If cannotWalk = False Then If cannotWalk = False Then
For Each Entity As Entity In Screen.Level.Entities For Each Entity As Entity In Screen.Level.Entities
If Entity.boundingBox.Contains(newPosition) = ContainmentType.Contains Then If Entity.boundingBox.Contains(Position2D) = ContainmentType.Contains Then
If cannotWalk = False Then If cannotWalk = False Then
If Entity.Collision = True Then If Entity.Collision = True Then
cannotWalk = Entity.WalkAgainstFunction() cannotWalk = Entity.WalkAgainstFunction()
@ -815,17 +815,17 @@ Public Class OverworldCamera
cannotWalk = Entity.WalkIntoFunction() cannotWalk = Entity.WalkIntoFunction()
End If End If
End If End If
ElseIf Entity.boundingBox.Contains(New Vector3(newPosition.X, newPosition.Y - 1, newPosition.Z)) = ContainmentType.Contains Then ElseIf Entity.boundingBox.Contains(New Vector3(Position2D.X, Position2D.Y - 1, Position2D.Z)) = ContainmentType.Contains Then
Entity.WalkOntoFunction() Entity.WalkOntoFunction()
End If End If
Next Next
Else Else
For Each Entity As Entity In Screen.Level.Entities For Each Entity As Entity In Screen.Level.Entities
If Entity.boundingBox.Contains(New Vector3(newPosition.X, newPosition.Y - 1, newPosition.Z)) = ContainmentType.Contains Then If Entity.boundingBox.Contains(New Vector3(Position2D.X, Position2D.Y - 1, Position2D.Z)) = ContainmentType.Contains Then
Entity.WalkOntoFunction() Entity.WalkOntoFunction()
End If End If
If Screen.Level.Surfing = True Then If Screen.Level.Surfing = True Then
If Entity.boundingBox.Contains(newPosition) = ContainmentType.Contains Then If Entity.boundingBox.Contains(Position2D) = ContainmentType.Contains Then
If Entity.Collision = True Then If Entity.Collision = True Then
Entity.WalkAgainstFunction() Entity.WalkAgainstFunction()
Else Else