Godot Version
Godot v4.7.stable.official [5b4e0cb0f]
Question
So I’ve been following Brackeys Godot tutorial, got to the enemy part and I’m experiencing some issues. Firstly the enemy doesn’t appear to spawn where I placed it on my tile map, instead it appears above the player but its just in the air and its animation doesn’t play at all. I suspect something with the Ray cast has to do with because when I remove those it just spawns in the regular place. But I’m not sure what exactly about the Ray Cast is causing the issue.
Before game starts:
After game starts:
extends Node2D
const speed = 40
var direction = 1
@onready var ray_cast_left: RayCast2D = $RayCastLeft
@onready var ray_cast_right: RayCast2D = $RayCastRight
@onready var animated_sprite_2d: AnimatedSprite2D = $AnimatedSprite2D
func _process(delta : float):
ray_cast_right.force_raycast_update()
ray_cast_left.force_raycast_update()
if ray_cast_left.is_colliding():
direction = 1
animated_sprite_2d.flip_h = false
if ray_cast_right.is_colliding():
direction = -1
animated_sprite_2d.flip_h = true
position.x = direction * speed * delta

