NWH Dyanmic Water Physics Question

nathanj

Active member
Hello,

I'm working on an integration for NWH Dynamic Water Physics based off your NWH Engine integration. It's mostly working, though very roughly at the moment. However, the main issue I have right now is that the Swim ability is set start automatically when it triggers a collider set to the Water layer. This works at the start but when I enter the boat and exit it the player no longer detects the Water trigger collider. The only way to get the character to detect it again is to disable and enable the collider. Obviosly, this is not ideal.

Can you think of any way to avoid this?

Also, is there a way to have the swimming ability start automatically without a collision? Basically, i'd like the swimming ability to start on start and always stay active. I've tried setting it to Manual and run TryStartAbility(Swim) through a custom code but that doesn't work for some reason.

For example, with my Swim ability set to Start Type Manual and this attached to my player
Code:
void Start()
    {
        UltimateCharacterLocomotion loco = GetComponent<UltimateCharacterLocomotion>();
        Ability swim = loco.GetAbility<Swim>();
        loco.TryStartAbility(swim);

    }

My player does not respond to swimming, though it does when the Collider detection starts the ability.
Thanks as always,
Nathan
 
Last edited:
Sorry to bump this but anyone able to give any insight on this? I feel like I might need to make a custom version of the Swim script and remove the Trigger detection but I'm not sure how to do this.

Thanks again,
Nathan
 
It does sound like you may need to go the custom route. The swim ability was designed to work with a trigger so it has the standard Unity trigger limitations/callbacks.
 
You mind directing me a bit further?

I've tried commenting out the checks in the swim code that use
Code:
m_DetectedTriggerObjectsCount
but this didn't make a differnce when I tried the above manual start.

Can you tell me where the actual detection is taking place?
 
CanStartAbility determines if the ability can be started, and that's where the swim ability determines if it can start. You'll want to start by modifying this method.
 
Couldn't figure out how to modify the CanStartAbility to get it to work, however, I did kind of find a work around.

The issue has to do with Teleport option being used on the Drive ability. If I disable it and play an animation sequence to enter and exit the canoe then the Swim ability maintains it's connection to the swimming trigger.

Going to add animations anyways so that will resolve this issue, and for now I can add a simple enable disable for the water collider when the player enters/exits the canoe but unfortunately I didn't resolve this issue in any meaningful way.
 
Top