![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | keidav |
I am having an issue where my 2D ray cast is not working after converting from 3.5.2. The ray target ($FloorChecker) value for y is set to 250 and not modified, this value and the following code is not working in 4.0, my old code was flipping an enemy using this script when reaching a cliff(no colliding) or walls. Everything but the raycast is working correctly:
@export var direction = -1
@export var detect_cliffs = true
func _ready():
if direction == -1:
$AnimatedSprite2D.flip_h = true
$FloorChecker.target_position.x = $CollisionShape2D.shape.get_size().x * direction
$FloorChecker.enabled = detect_cliffs
$AnimatedSprite2D.play()
func _physics_process(_delta):
calc_velocity = Vector2.ZERO
if is_on_wall() or not $FloorChecker.is_colliding() and detect_cliffs and is_on_floor():
direction *= -1
$AnimatedSprite2D.flip_h = not $AnimatedSprite2D.flip_h
$FloorChecker.target_position.x = $CollisionShape2D.shape.get_size().x * direction