update in the ability script

I'm coding a new ability: Swim and Dive.
I've followed the steps on the documentation: https://opsive.com/support/document...r-controller/character/abilities/new-ability/

And I have already created the class, but I'm getting a issue to activate the ability on the exact point I want.
It's set up in automatic, trigger (on the surface water) and the swimming and Idle animations runs great for me, except that....:
When the trigger enters, its when the character step on the surface, so the player starts to swim when he is already standing and not with the water at right altitude, lets say at his chest.
So I have tried to change the start activation to manual and override on trigger enter to calculate the exact high before playing the animation. But I get in troubles as:

I can't override on trigger update (it seems its not already coded on your class and on trigger enter is not enough)
I can't override on update,....

So basically I don't know how to get real time values when the character is moving inside the DetectObjectAbilityBase inherit class.

Any ideas?
 
I can't override on trigger update (it seems its not already coded on your class and on trigger enter is not enough)
I can't override on update,....
I'm not following - both OnTriggerEnter and Update are virtual so you can override.
 
ok thanks, Update inside ability is working, I don't know what happened before.

One more thing: I have tried to disconnect gravity from code:
m_CharacterLocomotion.AllowUseGravity = false;
m_CharacterLocomotion.UseGravity = false;
And even from the ability tab and it doesn't work for me. The character is swimming ok but it goes down and up on the slopes of the shore / underwater terrain.
Any ideas?

Maybe also it's good idea to block the "Y" component at sea level to block the movement? If so, how can I do it? Thanks
 
Last edited:
Any feedback on the above?

And one more thing: Related to the camera, I'm trying to get the pitch's camera so I can dive down / up the player on the diving ability.
I have tried all this but I don't find it. What is the code to get the Pitch?

using Opsive.UltimateCharacterController.Camera;
using Opsive.UltimateCharacterController.Camera.ViewTypes;
m_CharacterLocomotion........
 
Since this is related to your own ability it's really hard to debug from this end. If I were to debug this I would insert a breakpoint within CharacterLocomotion.Move and see why the gravity is still being applied.
 
OK, and related to the Camera,, I'm trying to get the pitch's camera so I can dive down / up the player on the diving ability.
I have tried all this but I don't find it. What is the code to get the Pitch?

using Opsive.UltimateCharacterController.Camera;
using Opsive.UltimateCharacterController.Camera.ViewTypes;
m_CharacterLocomotion........
 
Right now you can only get the active view type with CameraController.ActiveViewType. You can then check against the view type's type and cast it to the type that it is. In the next version I'll add a GetViewType method to the CameraController so you can get the reference more easily.
 
OK, I thought it was easier as I can see the pitch on the animator....

I'm getting some problems applying the position on the abilities: I want to limit the high of the character always to 0 (water plane) so the character can swim only on the water plane. I'm using this function but it's not working really god, Am I using on the right way? I'm using those 2 functions on the following code:
m_CharacterLocomotion.SetPosition and m_CharacterLocomotion.transform.position.y

public override void ApplyPosition()
{

var y = m_CharacterLocomotion.transform.position.y;
//If is above the water plane......
if (y > waterHeightLevel + heightOffset)
{
m_CharacterLocomotion.SetPosition(new Vector3(m_CharacterLocomotion.transform.position.x, waterHeightLevel + heightOffset, m_CharacterLocomotion.transform.position.z));
MySwimmingState = SwimmingState.Swimming;
GetComponent<Animator>().SetTrigger("SwimmingWaterLevel");
 
Due to my support load I'm not able to help create custom abilities, but if you take a look at the existing abilities and the new ability video you should be able to get a good idea on how everything is structured so you can model it off of them.
 
I followed the tutorial step for step and the ability is not detecting collider. The ability works perfectly when I set it to Button Down/Button Up. Has the collider setup changed since the tutorial was made?

ability.png

animator.png

collider.png
 
I followed the tutorial step for step and the ability is not detecting collider. The ability works perfectly when I set it to Button Down/Button Up. Has the collider setup changed since the tutorial was made?

View attachment 1601

View attachment 1602

View attachment 1603
Turns to the auto generated ultimate character controller "SPECIAL" layer wasn't setup to collide with the "Default" layer in the Unity Physics->Layer Collision Matrix. The Default layer had my collision object in it. Ticking that box fixed it.

collision-matrix.png
 
Top