In this 2D platform game im using the character platform controller to move around my character.
I made this box of water and when u get in u should be able to swin in, sink, and float and move on the surface unless when i press down i ca swin underwater again.
i already have most of it done, my main problems are when im on the surface, i have 2 colliders for the water, one in general and another just for the surface, my 3 problems are, i cant jump when floating, cant go underwater either, the floating system is far from what im looking for.
just showing some example of wat im using to make the character float on water and jump, im using the ‘MoveTowards’ function to force the player to float on the surface but as u cant see its using all axes instead of only the y axes because i dunno how to fix that
function OnTriggerStay (hit : Collider)
{
if(hit.gameObject.tag == "WaterSurface")
{
WaterSurfaceTouch = true;
movement.gravity = 0;
movement.maxFallSpeed = 0;
if (WaterSurfaceTouch == true)
{
gameObject.transform.position = Vector3.MoveTowards(transform.position, target.position, speed * Time.deltaTime);
}
if(Input.GetButtonDown ("Jump"))
{
myNewVelocity = Vector3(0,26,0);
setVelocity.SetVelocity(myNewVelocity);
}
}
}
any kind of tip would be nice