Help with deleting items affected by gravity

Godot Version

4.3

Question

Hello! Recently i’ve been learning Godot and after a bit of tutorials i’ve decided to give up on them and start to recreating some mechanics on the games i play, so, for starters i tried to make the echoes system from The legend of zelda: Echos of Wisdom.

It kinda works properly, but now i’m facing two problems:
1 - I wanted to if the echoe has affected_by_gravity variable enabled, i wanted for it to be deleted after falling from a certain distance, i tried making it RigidBody3d, Tried using is_on_floor but nothing seems to work properly and i’d like your help on it.
2 - I also wanted to rotate the echoe using the player’s pivot, but it just works in the other way.

Here’s a bit of gameplay: Watch Echoes of Wisdom Prototype | Streamable
Here’s a bit of the EchoComponent Code (I removed the parts that didn’t work, which ways the entirety of the phys_process)

class_name EchoComponent
extends RigidBody3D

@export var is_learnable := true
@export var is_pushable := false
@export var destroy_on_fall := true
@export var cost_to_spawn := 1
@export var affected_by_gravity := true

func _ready() -> void:
    if !affected_by_gravity: self.gravity_scale = 0

I was planning on using a Raycast to check if its colliding with something then calculate the distance traveled to check if it should be destroyed or no, but i think that might not be the most efficient way to do this?

When the obect spawns, save the global position.y in a variable and use it to check if the object should break or not when it falls.

If you have your collision groups set correctly you should be able to use the rigidbody body_entered() signal to check if the object is touching the ground.

1 Like

This does solve my problem, thanks!
I’ll use the character’s height as max fall height for the destructable object <3

1 Like

Awesome!

1 Like

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