does anyone have a swimming and watershader script i can use..... or any tips for creating one myself.... cheers
i am an absolute beginner and i would appreciate any help in creating a script...... or if anyone has a script i would appreciate that..... cheers
Answer by whereswaldo · Jan 29, 2017 at 02:16 AM
This should help you with the movement part of being under water, but when you use this make sure the player has air control. Just attach this to a trigger on the water:
public class GravityChange : MonoBehaviour {
void OnTriggerEnter(Collider Collider)
{
if (Collider.gameObject.tag == "Player")
{
Physics.gravity = new Vector3(0, -1F, 0);
}
}
void OnTriggerExit(Collider Collider)
{
if (Collider.gameObject.tag == "Player")
{
Physics.gravity = new Vector3(0, -10F, 0);
}
}
}
thank you! :)
tell me if i have got this right.... i attach this script to the water? what do you mean "attach this to a trigger on the water'???
cheers
Give the water a box collider and set it as trigger. $$anonymous$$ake sure this trigger in roughly the same size as the water. Add the script and the collider to the water.
sorry, but what is "air control"????
cheers, and sorry :)
Answer by MrCrompz · May 22, 2021 at 03:21 AM
I was trying to do this and can't as well. I followed whereswaldo's advice and it didnt work. Mine is 2d.. .