Support Forum

Falling through floor when calling from another script

Hi!

I have Seeker/Destination/AIPath/Funnel/RVO on a character. If I turn on CanMove, it works fine.

If, instead, I call:
aiPath.MovementUpdate(Time.fixedDeltaTime, out var nextPos, out var nextRot);
animatorTransform.position = nextPos;

The character falls through the floor. Setting gravity on the AIPath script to Vector3.zero stops it falling, but of course it doesn’t position its Y value properly.

Can someone help with this please?

Thanks!

EDIT: If it helps, the ideal outcome here is I want a black box solution. I basically just want the position the AIPath WOULD place me in if I had CanMove checked in. Is there anyway to just get that value? Everything I’ve tried fails to match how it behaves by just checking in CanMove.

Hi

If you call aiPath.FinalizeMovement(nextPos, nextRot) then it will work exactly like with canMove enabled.
The agent will do some raycasting inside FinalizeMovement to make sure it doesn’t fall through the ground. You can subclass the AIPath script and expose the currently protected RaycastPosition method to use the exact same logic.

Thank you for your reply!

Unless I’m mistaken, calling Finalize Movement would indeed work just like CanMove, along with the actual movement (which is what I don’t want), but your reply provides perfect guidance on what to do for my own implementation, so thank you!

If you wouldn’t mind some unsolicited feedback, perhaps a future release could explicitly include a means of disabling movement itself while still taking advantage of the movement calculations and exposing the desired new position for people who want to black box the positioning/pathing logic while actually moving the character through other means.

Anyway, I hope you have a great day. Thank you for providing such a powerful product and excellent support!

1 Like