Block Height Change and Crawl abilities when swimming

Hi,

I'm using the Agility and Swimming add-on packs in First Person mode. I have slightly adapted the Height Change ability (making a new one called Sneak which is essentially the same as Height Change but which also reduces speed by 50%). Crawl I have working on a 'whenever you like' toggle basis.

I have a problem when a player enters water (and thus begins swimming) when in either the Sneak or Crawl state: the state is retained. In the case of Sneak (which, again, is just Height Change with a speed mod), the character can still swim, but in a very clumsy manner. When in the Crawl state, he can only sort of crawl along the surface of the water. Is there a way to cancel both/either of the Sneak/Crawl states when Swim commences? I'm pretty certain there is, but I can't figure it out.

Thanks in advance
Anasta
 
You can use the state system to create a new preset which disables the Height Change abilities when the Swim ability is active.
 
Thanks, Justin. I thought that was where to look, but I'm really quite unsure how to use the states and presets. I guess I'll give it another go and see what happens.
 
You'd basically just want your swim ability to activate a state, e.g. "Swim", then in the UltimateCharacterLocomotion component, you'd add a state preset to each of the abilities you want to disable and have that preset be assigned to the "Swim" state. That preset would set the "enabled" property of that ability to false.
 
Nope, not a clue :cry:
I've read the documents and watched several Youtube clips. Unfortunately, I just can't get my head round this.
 
Sorry, I must be failing hard somewhere. No luck whatsoever with this. Here is what I've done:

1. Ensured the Swim and Crawl abilities work as intended (they do).
2. In the inspector, called the Swim ability's state 'Swim'.
3. In the inspector, added a state to Crawl called 'NoCrawlWhenSwimming'.
4, In the state's preset, added State: Swim.
5. In the state's preset, added Enable: False.

Is this right? It doesn't seem to make any difference though... the character remains in the crawling state when he enters water (when Swim would normally start).

Also, a new issue I've discovered which I can't explain. If swimming underwater normally, the first time (but only the first time) the character hits the bottom of the swimming pool he takes damage as if he has fallen. If I deactivate fall damage this doesn't happen, so it must be related.

Thanks
Anasta
 
Is the state name for that preset set to "Swim"? And is the Crawl ability being disabled when entering the Swim state? (The checkbox next to the ability in the list tells you if it's enabled or disabled.)

Also I suppose this method might not quite work if you're already in the Crawl state before entering the water (the Crawl ability should still get disabled, but I'm not 100% sure if the Crawl state will get disabled at the same time). If so, what you might need to do is block any other Crawl state preset with the Swim state.

As for the fall damage, you should be able to add a new state preset to the character's Character Health component, to set "Apply Fall Damage" to false, and have this preset activated by the Swim state.
 
I'm sure it's me doing something wrong. I'll give this another shot tonight and see what happens. Luckily, I make backups of my project every time I change something, so I'm able to experiment freely.
 
Bah, no success at all. I think the fundamental issue here is that I don't understand where to add the states and presets. I've got to get this right, or my understanding of the whole Opsive thing will be very limited... I'll show some screenshots of what I've done, then perhaps I can be redirected if I'm getting it the wrong way round.

So, in short, I want the Swim ability to cancel the Crawl ability.
Here is what I have in the Swim inspector:

swim.png
My understanding is that this activates a state called 'Swim' whenever my character begins to swim. Right?

Here is what I have placed in the Crawl inspector:

crawl.png
My understanding is that this sets up a state called 'DontCrawl' that will become active when the state declared in the preset is true. Right?

And the contents of that preset:

preset.png
So, when the player gets into the water, the Swim state activates and the Don't Crawl state should activate (because the State it's looking for is Swim) and this makes the crawl ability's enabled status FALSE. Right?

This, however, doesn't seem to do anything. The Don'tCrawl state never activates.

Or, more likely, have I got this completely wrong?

Thanks in advance - I know I'm a pest.
Anasta
 
That second step is where you're getting confused - what you've actually set here is that when a state called "DontCrawl" gets activated, the settings in that preset will get applied. But there's no state called "DontCrawl", so it never activates. The "Name" field is what state needs to be active for its associated preset to be used. So what you should actually have is the state name field be "Swim" and the preset just has the Enabled property set to false. So when the Swim ability activates the "Swim" state, that preset will activate and disable the Crawl ability.
 
Bingo! That's the answer. Works great to prevent the fall damage and negate the Sneak (height change) ability. It doesn't work on Crawl yet, but I think this is real progress. Thanks Andrew and Justin for your help with this. Awesome stuff!
 
Top