i was wrong!


version 3.5.2 topic i was wrong!

Here is another thing to consider. How to build complex objects. Some enemy with a sprite or animated sprite with a collision things. I started always with a Node2D. Wrong!

Start with KinematicBody2D first.

EnemyBat: KinematicBody2D: root node
_CollisionShape2D: Rectangle2D
_AnimatedSprite: or Sprite to have a picture

Whaaaay? (Why short) Because otherwise inside the attached script on the root node you would not have function called move_and_collide ROFL. That is why. Do it correctly. Like me. LOL.

extends KinematicBody2D

# direction of moving
var velocity = Vector2.ZERO

var speed = 100

# start
func _ready():
	pass

# update
func _process(delta):
	if Input.is_action_pressed("ui_page_down"):
		velocity.y = speed
	elif Input.is_action_pressed("ui_page_up"):
		velocity.y = -speed
	else:
		velocity = Vector2.ZERO
		
	var collision_info = move_and_collide(velocity * delta)
	if collision_info:
		print(collision_info)

Damn these two kinematic object do not overlap they hit and one will push another away :D.