Impossible get under terrain with labber
Hi, I made labber and there is one thing because when I'm gettin down on the labber then I can get under terrain. I've put collider exactly where terrain is and with big X and Z positions but it was still possible to get under the terrain, including map. What's code in C# to make it impossible?
Comment
Forgot guys, here is code:
using UnityEngine;
using System.Collections;
using UnityStandardAssets.Characters.FirstPerson;
namespace FPSSystem
{
public class LadderClimb : $$anonymous$$onoBehaviour
{
public Transform chController;
public bool inside = false;
public float heightFactor = 3.4f;
private FirstPersonController FPSController;
void Start()
{
SetInitialReferences();
}
void Update()
{
if (inside == true && Input.Get$$anonymous$$ey("w"))
{
chController.transform.position += Vector3.up / heightFactor;
}
else
if (inside == true && Input.Get$$anonymous$$ey("s"))
{
chController.transform.position += Vector3.down / heightFactor;
}
else
if (inside == true && Input.Get$$anonymous$$ey("a"))
{
chController.transform.position += Vector3.left / heightFactor;
}
else
if (inside == true && Input.Get$$anonymous$$ey("d"))
{
chController.transform.position += Vector3.right / heightFactor;
}
}
void SetInitialReferences()
{
FPSController = GetComponent<FirstPersonController>();
}
void OnTriggerEnter(Collider col)
{
if (col.gameObject.tag == "Ladder")
{
FPSController.enabled = false;
inside = !inside;
}
}
void OnTriggerExit(Collider col)
{
if (col.gameObject.tag == "Ladder")
{
FPSController.enabled = true;
inside = !inside;
}
}
}
}
Your answer
Follow this Question
Related Questions
The laser problems 0 Answers
how to make a max number on counter. 1 Answer
Health Script 2 Answers
Why cant I access the same function twice? 0 Answers
How can i make sure the script will work only on the attached object ? 1 Answer