Networked Character Controller Issue (v2)
Posted: Tue Apr 28, 2020 9:37 pm
I have taken a look at the thread regarding Character Controllers in v2, and it helped me tremendously in getting mine setup, so thank you Norbo and everyone else for that.
My issue is pretty unique, and I am not sure how to replicate it. I copied verbatim the code from the following demo files:
-CharacterController.cs
-CharacterNarrowphaseCallback.cs
-CharacterMotionConstraint.cs
-DemoPoseIntegrator.cs
-SimpleThreadDispatcher.cs
I am creating my character in the same order and with the same values as the demo:
The simulation is setup the same as the demos:
The issue comes when running the server. It appears that the CharacterControllers.TryReportContacts ethod is not being called, as my character does not move (confirmed that messages to/from the server are being seen, with the correct values going in and no changes coming out.)
BUT where it get really weird is if I attach the visual studio debugger to my server process and put a breakpoint in the TryReportContacts method everything starts to work! My client can move, the breakpoint is being hit, everything seems to be running fine.
If I leave the server running, disconnect the client, remove the breakpoint, and login with the client again...nothing. No movement.
I have no idea where to begin with this one. Please help!
My issue is pretty unique, and I am not sure how to replicate it. I copied verbatim the code from the following demo files:
-CharacterController.cs
-CharacterNarrowphaseCallback.cs
-CharacterMotionConstraint.cs
-DemoPoseIntegrator.cs
-SimpleThreadDispatcher.cs
I am creating my character in the same order and with the same values as the demo:
Code: Select all
var shape = new Capsule(0.5f, 1);
((BEPUPhysics)player.Physics).ShapeIndex = CharacterControllers.Simulation.Shapes.Add(shape);
((BEPUPhysics)player.Physics).CharacterControllers = CharacterControllers;
int bodyHandle = ((BEPUPhysics)player.Physics).BodyHandle = CharacterControllers
.Simulation.Bodies.Add
(
BodyDescription.CreateDynamic
(
new Vector3(obj.Position.X, obj.Position.Y, obj.Position.Z),
new BodyInertia { InverseMass = 1f / MASS },
new CollidableDescription(((BEPUPhysics)player.Physics).ShapeIndex, SPECULATIVE_MARGIN),
new BodyActivityDescription(shape.Radius * 0.02f)
)
);
ref var character = ref CharacterControllers.AllocateCharacter(bodyHandle);
character.LocalUp = new Vector3(0, 1, 0);
character.CosMaximumSlope = (float)Math.Cos(MAXIMUM_SLOPE);
character.JumpVelocity = JUMP_VELOCITY;
character.MaximumVerticalForce = MAXIMUM_VERTICAL_GLUE_FORCE;
character.MaximumHorizontalForce = MAXIMUM_HORIZONTAL_FORCE;
character.MinimumSupportDepth = shape.Radius * -0.01f;
character.MinimumSupportContinuationDepth = -SPECULATIVE_MARGIN;
Code: Select all
BufferPool = new BufferPool();
ThreadDispatcher = new SimpleThreadDispatcher(Environment.ProcessorCount);
CharacterControllers = new CharacterControllers(BufferPool);
Simulation = Simulation.Create(BufferPool, new CharacterNarrowphaseCallbacks(CharacterControllers), new PoseIntegratorCallbacks(new Vector3(0.0f, -10f, 0.0f)));
BUT where it get really weird is if I attach the visual studio debugger to my server process and put a breakpoint in the TryReportContacts method everything starts to work! My client can move, the breakpoint is being hit, everything seems to be running fine.
If I leave the server running, disconnect the client, remove the breakpoint, and login with the client again...nothing. No movement.
I have no idea where to begin with this one. Please help!