The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates. | Twitter

0 votes

So i've previously asked a question about how to calculate the distance between a player and an object, the object was a softbody node, community help was amazing, but the answers didn't work, i just want to point out do NOT use soft body for this kind of tasks, it will always be at position (0,0,0) no matter where u place it, thats why the answers i was given didn't work, idk if it's a bug in godot or something else, anyway now i'm using a rigidbody3D nd everything is working fine, however i want to create different rigidbodies all under a group called "object", nd if the distance between an element of the group nd player is less than 4 the function collect gets applied on it (i'm collecting the elements in a Listitem node), i know about gettree.getgroup("group name", "function") but i just wanna apply that only on the elements that r far than the player by less than 4, is the apprach i'm trying to achieve correct? if not whats the right approach nd how to achieve it

Godot version 3.5.1
in Engine by (59 points)
edited by

1 Answer

0 votes

You may have to create a group manager for this

but in simpler terms, add/remove the nodes of interest to another group or loop the group for the affected


func _process(delta):

    for obj in get_tree().get_group("object"):
        if player.global_transform.origin.distance_to(obj.global_transform.origin) < 4:
by (6,942 points)

@wakatta ty, i've tried to achieve similar approach, but now there's another bug i'm confused about, i've ended up asking another question lol

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.