#raycasting with pointlight2d

1 messages · Page 1 of 1 (latest)

mental veldt
#
func player_in_light():
    var space_state = get_world_2d().direct_space_state
    color = white
    if player:
        var query = PhysicsRayQueryParameters2D.create(position, player.position)
        query.exclude = [self]
        var result = space_state.intersect_ray(query)
        if result && result.collider.name == 'Player':
            color = red

func _on_area2D_body_entered(body):
    if body.name == 'Player':
        player = body

func _on_area_2d_body_exited(body: Node2D) -> void:
    if body.name == "Player":
        player = null

not sure what im missing to make the player not being seen by the pointlight collision

#

it might be my colliders on my staticbody2d but i wouldnt think so