- Home /
Changing Far Clip Plane via Script doesn't work!
Hello
I have my main camera following my "Player". I want its FarClipPlane to increase from 300 (my default value) to 700 when "Player" collides an invisible box with a box collider set to triggered. I attached a script to that invisible box and these are two types of codes I've written:
1)
public GameObject myCamera;
public void OnTriggerEnter(Collider Other)
{
if (Other.name == "Player")
{
myCamera.GetComponent<Camera>().farClipPlane = 700f;
}
}
2)
public Camera myCamera;
public void OnTriggerEnter(Collider Other)
{
if (Other.name == "Player")
{
myCamera.farClipPlane = 700f;
}
}
I then dragged and dropped the main camera into the reference slot and pressed "Play", but weirdly none of them changed the far clip plane value.
I'd appreciate it if someone can help me with this and correct me.
Thank you in advance.
Answer by Siavash1989 · Aug 30, 2020 at 10:22 PM
I'm not sure if this forum is dead or not, but I've posted like about 10 questions since maybe last year and, so far, I haven't received any answer for any of them, even when I couldn't find similar questions and answers here to clarify the issue for me. Maybe it was active one day, but now, really, what's the point of this forum? Even moderators are always quiet! Now feel free to close my thread. It's not gonna lead me to any clear answer anyway as always.
Your answer
Follow this Question
Related Questions
Strange lighting on large-scale objects when using fog in VR 2 Answers
Prevent objects from disappearing when zooming in on an orthographic scene? 1 Answer
Can I simulate an object from 30000 meters away? 1 Answer
Unity5 scene camera clips planes 0 Answers
Unity - How to hide the Far Clipping Planes of camera? 1 Answer