Hi everyone. I am a beginner in GD script and I am learning via tutorials on how to make games. I just stumbled upon an issue which says:
Function "is_on_floor()" not found in base self.

Here is my code:

extends Actor

func _physics_process(delta: float) -> void:
	var motion = Vector2(0, 20)
	var collision =move_and_collide(motion)
	var velocity: = Vector2.ZERO
	var speed: = Vector2(3.0, 1000.0)
	var direction := Vector2(
    
	Input.get_action_strength("move_left") - Input.get_action_strength("move_right"),
    -1.0 if Input.is_action_just_pressed("jump") && is_on_floor() else 1.0)

	velocity = speed * direction
	move_and_collide(velocity)`
  • Bandy There is the problem. RigidBody2D doesn't have an is_on_floor() method, only CharacterBody2D does.

What is that Actor class? Is it a subclass of CharacterBody2D/3D? Because those have an is_on_floor() method.

Which Godot version are you using?

    Toxe The Actor Class is a Rigid Body 2D and I am using Godot Engine Version v4.1.1

    • Toxe replied to this.

      Bandy There is the problem. RigidBody2D doesn't have an is_on_floor() method, only CharacterBody2D does.

        Toxe Is there any other way I could use this command on a Rigid Body 2d

        • Toxe replied to this.

          Bandy I don't think so but you can probably check yourself with what other object you collided and set a flag if it is the ground.