1.5 KiB
Executable file
1.5 KiB
Executable file
#+title:Flyin#+title: Section 04 - Lesson 08 | Collisions: Hitting the floor
Notes
when a character body2d hits the floor
- velocity is set to 0
- is_on_floor is set to true
create a floor
to create a floor we are going to use a StaticBody2D
- make this as a seperate scene
- add root node StaticBody2D
- add CollisionShape2D as child
- in collisionshape2D inspector go to shape and pick rectangle shape
- stretch the rectangle across the scene
- save scene
add barrier to game
- add the barrier scene to the game scene
- put it at top of screen or whereever you like
- Ctrl+D to create another one and move it to the floor
when plane hits floor stop it from moving
- in physics process func check if 'in on floor'
- if so than invoke die
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _physics_process(delta: float) -> void:
# ...
if is_on_floor() == true:
die()
func die() -> void:
set_physics_process(false)
end properller animation
- switch to plane scene
- Cmd + drag AnimationSprite to script
- in die set the variable to the sprite to 'stop()'
func die() -> void:
set_physics_process(false)
animated_spirte_2d.stop()