#Customizing decollisions for character controller (rival)

1 messages · Page 1 of 1 (latest)

broken elm
#

We ran into a problem where certain abilities that have root motion will result in two character being inside each other and then decollisions logic would put one on top of another. (we temporarily disable collisions during root motion so movement is not prevented)

So from perspective of player it looks like: large Ogre jumps into player and then suddenly Ogre is standing on top (literally above head) of player. Our expected behavior would be to resolve player outside of Ogre and only horizontally.

But we are a bit lost on how we can actually achieve it.
@turbid flare would appreciate any assistance on this.

tall scaffold
#

Wouldn’t it be better to recalculate the amount of root motion on the fly to place the ogre directly in front of the player instead of inside?

broken elm
#

Ideally - it'll be knockback effect, but that's not the case atm

turbid flare
#

I think there's 2 ways you could go about this

1-Make characters never intersect eachother
If all root motion movement first gets translated into a characterBody.RelativeVelocity and then gets "solved" by the character update, you should theoretically never end up with characters intersecting eachother.

Let me know if that's already what you're doing though; that would mean I have to investigate why characters intersecting ends up being possible

You should also customize the IsGroundedOnHit character callback in order to make characters unable to consider themselves grounded on other characters, so they won't just stand on top of eachother.


2-Customize decollision
The character doesn't offer an obvious way to customize decollision (I'll take note of it as something worth adding in the future). But here's what you could do:

In your character PhysicsUpdate, where we call all the main character update steps, you can insert a step right before CharacterAspect.Update_MovementAndDecollisions. Here you can do a CalculateDistance check and move the character transform out of the collision before the regular character decollision update happens.

You can make this efficient by only doing this manual decollision step if characterBody.GroundHit.Entity exists and characterBode.GroundHit.Fraction <= 0f. That way, you'll only have to check manual decollisions when the CharacterAspect.Update_Grounding ground check cast already determined that it detected a hit that was overlapping the character

#

You should also customize the IsGroundedOnHit character callback in order to make characters unable to consider themselves grounded on other characters, so they won't just stand on top of eachother.

Actually I'd say you should try this as a first step. Character decollision has special logic against grounded hits, where it decollides fully vertically. If it doesn't consider other characters as valid grounding hits, maybe it'll decollide as you expect and you won't need anything else

broken elm
#

So I guess our plan so far:

  1. Make sure you can't be grounded off other characters
  2. Add custom decollision step
#

I suppose we just need to customize this method

        public bool IsGroundedOnHit(ref RivalUpdateContext context, ref KinematicCharacterUpdateContext baseContext,
            in BasicHit hit, int groundingEvaluationType)
        {
            return _aspect.Default_IsGroundedOnHit(
                in this,
                ref context,
                ref baseContext,
                in hit,
                in _settings.StepAndSlopeHandling,
                groundingEvaluationType);
        }
broken elm
#

So plan 1 success, but not fully. Creatures cannot stand on top of each other anymore. But they resolve fairly - as in, 50:50.
Meanwhile we want to control somehow who gets pushed out. And ideally it'd be calculated based of creature mass/some property.

turbid flare
#

Another possible solution would be to turn off character-character collisions, and instead implement your own "soft collisions":

  • modify CanCollideWithHit so that characters can never collide with other characters
  • add a system that finds overlapping characters and pushes them away from eachother
broken elm
#

unlikely it'll be any good. We don't want characters to walk into each other in the first place. So pushing them out as additional step is just going to create movement where there shouln't be any