Underwater Effect Help
I Am A Kind-Of Noob To Unity Scripting, And I Need Help. Can Anyone Help Me Write A Script, Where When The Character's Camera Is On Level With Or Under The Water, Bluish Fog Appears. And If Possible Without Shaders. Here Is My Script So Far:
using UnityEngine; using System.Collections;
public class UnderWater : MonoBehaviour {
public Camera cam;
private float campos;
public GameObject player;
void Start() {
campos = cam.transform.position.y;
}
void OnTriggerEnter(Collider other) {
if(other.name == "MainCamera"){
if (other.transform.position.y -= this.transform.position.y) {
}
}
} }
Please Help Me Finish It.
-TCE
A few things:
What do you mean by "without shaders"? You can't get fog without shaders, be it image effects or the legacy fog system (which you generally shouldn't use nowadays).
Setting the "campos" variable in the start function will only set it at the beginning of the scene.
For OnTriggerEnter to work you have to have a rigidbody and collider attached to the camera, which may not be the best of ideas.
Answer by CodeEmperor · Nov 14, 2016 at 02:39 PM
@Namey5 Thank You So Much. I've Worked It Out Now, And Also Thank You For Your Help. I've Changed It, So Now It Is Directed At The Player, Not The Camera.
Thanks Again,
-TCE