Enemy somehow doesnt move on oneway platform

Godot Version

<stable4.2>

Question

<As title says, enemy somehow doesn’t move on one-way platform. the collision layer of the ground is set to 1, and one-way platform is set to 10. Enemy’s collision mask is set to 1 and 10. What am I doing wrong? >

Can you show your movement code for the enemy?

enum States {IDLE, AIR}
@onready var state: States = States.IDLE

func _ready():
	pass

func _physics_process(delta):
	$Label.set_text(States.keys()[state])
	match state:
		States.IDLE:
			if !is_on_floor():
				state = States.AIR
			velocity.x = speed * direction
			velocity.y += gravity * delta
			move_and_slide()
			$AnimationPlayer.play("idle")
			if state == States.IDLE:
				if is_on_wall() or not $RayCast2D.is_colliding():
					direction *= -1
					self.scale.x *= -1
		States.AIR:
			if is_on_floor:
				state = States.IDLE
			$AnimationPlayer.play("idle")
			velocity.y += gravity * delta

Whats the state of the enemy when hes on the oneway-platform?

I want it to be state idle

Yes that what i thought. The question is, is it currently in Idle or in Air?

its in idle state and rapidly turn left and right endlessly

Can you make a screenshot of your enemy scene?


スクリーンショット 2024-07-22 212614
スクリーンショット 2024-07-22 212632

what the collision mask of your raycast2d?

1 Like

okay. I guess Im dumb lol. it was raycast2d

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.