0 votes

I have a 3D enemy that moves towards the player when they are in range. The enemy for some reason moves down into the floor the closer it gets to the player. is this a bug? any ideas how to fix.

in Engine by (271 points)

You have to show us the code that you are using for your enemy's movement.

I'm using the distance between characters form my movement method. I should also mention that I'm using rigid body and not kinematic body.

var colliderBounds = get_shape(0).get_extents();
        var posOffset =  Vector3(self.get_translation().x + colliderBounds.x, self.get_translation().y , self.get_translation().z + colliderBounds.z);
        var moveTo = (target.get_translation() - posOffset);
        self.global_translate(Vector3().linear_interpolate(moveTo, moveSpeed * delta));

The problem could be that you are moving a rigid body with set pos, rigid bodies are meant to be moved with forces and managed by the physics engine.

Not sure what happens here exactly but the engine may be trying to work over the bodies and get bad collision data.

So, if not using physics, don't use bodies (at least, not rigid bodies)

As far as I've seen and tested using translate to move a rigid body does still allow it to be controlled by the physics engine. My problem that I just realized was that the physics engine was also controlling rotation for my character which is something that you do not want to happen when using rigid body for character motion. setting the rigid body to character which disabled rotation by the physics engine solved my problem.

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 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 webmaster@godotengine.org with your username.