improve floor normal checks
This commit is contained in:
@@ -117,26 +117,34 @@ static func raycast_down(
|
||||
var from := pos + Vector2.UP * (shape.size.x + 1)
|
||||
var to := pos + Vector2.DOWN * (shape.size.x + 1)
|
||||
|
||||
var result: Dictionary = {}
|
||||
|
||||
var query_center := PhysicsRayQueryParameters2D.create(from, to)
|
||||
var result_center := space_state.intersect_ray(query_center)
|
||||
if result_center:
|
||||
return result_center
|
||||
if result_center and result_center["normal"] != Vector2.ZERO:
|
||||
if result_center["normal"] == Vector2.UP:
|
||||
return result_center
|
||||
result = result_center
|
||||
|
||||
var query_left := PhysicsRayQueryParameters2D.create(
|
||||
from + Vector2.LEFT * half_width, to + Vector2.LEFT * half_width
|
||||
)
|
||||
var result_left := space_state.intersect_ray(query_left)
|
||||
if result_left:
|
||||
return result_left
|
||||
if result_left and result_left["normal"] != Vector2.ZERO:
|
||||
if result_left["normal"] == Vector2.UP:
|
||||
return result_left
|
||||
result = result_left
|
||||
|
||||
var query_right := PhysicsRayQueryParameters2D.create(
|
||||
from + Vector2.RIGHT * half_width, to + Vector2.RIGHT * half_width
|
||||
)
|
||||
var result_right := space_state.intersect_ray(query_right)
|
||||
if result_right:
|
||||
return result_right
|
||||
if result_right and result_right["normal"] != Vector2.ZERO:
|
||||
if result_right["normal"] == Vector2.UP:
|
||||
return result_right
|
||||
result = result_right
|
||||
|
||||
return {}
|
||||
return result
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
|
||||
Reference in New Issue
Block a user