Godot Version
4.4.1 on Windows using C#
Question
Hello,
I have an enemy that walks to the player. I am using a custom characterbody that pushes any Rigidbodies it touches away. I want the enemy to walk straight through the boxes and push them away. However it seems to be built into the NavigationAgent that it will try to avoid walking into RigidBodies. Is there any way to turn this off?
btw. I am not talking about NavigationAgent3D.AvoidanceEnabled this turns off avoidance with other Characterbodies but I can find no way to turn avoidance off with RigidBodies.
Here is an Image:
(The enemy will not attempt to keep moving and never actually touches the box)
Here is my custom CharacterBody3D
using Godot;
using System;
[GlobalClass]
public partial class PhysicsCharacter : CharacterBody3D
{
[Export] public float mass = 1;
public override void _Ready()
{
}
public override void _Process(double delta)
{
}
public override void _PhysicsProcess(double delta)
{
PushPhysicsBodies();
}
private void PushPhysicsBodies()
{
const float PUSH_MULTIPLIER = 3;
for (int i = 0; i < GetSlideCollisionCount(); i++)
{
KinematicCollision3D collision = GetSlideCollision(i);
if (collision.GetCollider() is PhysicsBody body)
{
Vector3 pushDirection = (-collision.GetNormal()) * new Vector3(1, 0, 1);
float velocityDelta = Velocity.Dot(pushDirection) - body.LinearVelocity.Dot(pushDirection);
velocityDelta = MathF.Max(0, velocityDelta);
float massRatio = MathF.Min(1, mass / body.Mass);
float pushForce = massRatio * PUSH_MULTIPLIER;
body.ApplyImpulse(pushDirection * velocityDelta * pushForce, collision.GetPosition() - body.GlobalPosition);
//body.ApplyCentralImpulse(pushDirection * velocityDelta * pushForce);
}
}
}
}