Solo_Odyssey
Member
I know the swimming ability triggers when the character enters the box trigger works well on flat waters but looks bad with wave heights that are constantly changing like in a ocean. Any pointers on how to integrate and take into account the wave height and take into account of the wave height of the shader?
Custom Water Assets
The Swim ability is designed to be able to work with other water assets than what is
included in the demo folder. By default the Swim ability will determine the height of the
water by the top of the trigger’s bounding box, but this can also be set to a custom value. In
order to set a custom value the SetWaterSurfacePosition method can be called on the Swim
ability. This method takes a float which specifies the upper vertical position of the water
plane. In the example below the position will be set to a value of 5.
using UnityEngine;
using Opsive.UltimateCharacterController.Character;
using Opsive.UltimateCharacterController.Character.Abilities;
using Opsive.UltimateCharacterController.AddOns.Swimming;
public class MyObject : MonoBehaviour
{
[Tooltip("The character that contains the swim ability.")]
[SerializeField] protected GameObject m_Character;
/// <summary>
/// Sets the water surface position.
/// </summary>
private void Start()
{
var characterLocomotion =
m_Character.GetComponent<UltimateCharacterLocomotion>();
var swimAbility = characterLocomotion.GetAbility<Swim>();
swimAbility.SetWaterSurfacePosition(5f);
}