0 votes

I have a State Machine-driven approach to handling actions in the game world. I have a specific state thrown when a player KinematicBody conducts a transition near an object in the game world. Inside this state, I need to get all the colliding objects, so I can pull out the applicable item type and add that to the player's inventory.

#player's physics process
func physics_process(delta):
    if(Input.is_action_pressed("INTERACT")): # E button pressed
        $FSM3D/States/Interact.enter("Idle", "InteractWithObject", get_node(".")) # top level node is parent KinematicBody

# Inside the Interact
func enter(fromStateID=null, fromTransitionID=null, inArg0=null,inArg1=null, inArg2=null):
    #inArg0 is the active Player node from the calling class, which is KinematicBody
    var player = inArg0
    var collisions = player.get_colliding_bodies() #Not working, not sure what method to use

    if player.get_slide_collision(0):
        var element = player.get_collider()
            # HPRecovery1 is the name of the element in the game world, a Mesh/RigidBody
        if element == "HPRecovery1":
            print("Colliding with HPRecovery")
                    # Move to Inventory

I am not clear on what method to use to get all colliding meshes, if such a method exists for deferred instances of an object. What would be the best approach to get collided objects inside the State?

asked Aug 12, 2018 in Engine by Cameron Kilgore (61 points)

Please log in or register to answer this question.

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 How to use this Q&A? before posting your first questions.