i was wrong!
Godot - game development for homies » Devlog
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.
Godot - game development for homies
Status | Released |
Author | Bastian |
Genre | Educational |
Tags | Godot |
More posts
- loading resources with gdscript4 days ago
- physics collision and layers7 days ago
- tool ghosts8 days ago
- storing player position8 days ago
- component campfire8 days ago
- how to control things in a scene component9 days ago
- camera 2D9 days ago
- component : fadein10 days ago
- blocking my view eh?10 days ago