0 votes

I am trying to create a third person character.
I have this setup for the character: https://imgur.com/a/HZmDpPZ

This is an extract of my orbit camera code:

    // This gets called in the _Ready() method. It finds the KinematicBody (which is root) child shapes.
    // I checked using a GD.Print and it does indeed add the collision shape to the ExcludedObjects.
    private void ExcludeParentChildColliders()
    {
        Godot.Collections.Array nodes = TargetNode.GetChildren();

        foreach(Node node in nodes)
        {
            if(node is CollisionShape)
            {
                CollisionShape collider = (CollisionShape)node;
                AddExcludedObject(collider.Shape.GetRid());
            }
        }
    }

    // Called every frame. 'delta' is the elapsed time since the previous frame.
    public override void _Process(float delta)
    {
        // Check look up/down limits.
        if(Rotation.x < -Math.PI / 2)
        {
            Rotation = new Vector3((float)-Math.PI / 2, Rotation.y, Rotation.z);
        }
        else if(Rotation.x > Math.PI / 2)
        {
            Rotation = new Vector3((float)Math.PI / 2, Rotation.y, Rotation.z);
        }

        base.Rotation = Rotation;
    }

For some reason, the collider of the player is still sometimes detected causing the effect here: https://youtu.be/PFAAiObl4Ow

Any suggestions on what causes this problem and how to fix it would be appreciated.

in Engine by (29 points)

1 Answer

0 votes

So I have found an answer, apparently don't add to the exclusion the collision shape but add the kinematic body that uses the collision shape.

by (29 points)
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.
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 webmaster@godotengine.org with your username.