Hey,
I ran in a bit of an issue with the CharacterController. The update method is called twice, what causes problems with controlling the character. This is the shortest amount of code to cause this problem on my computer.
I have my settings for the CharacterController like this: Center is at 0, 0.95, 0; Radius is 0.4; Height is 1.85; The character is slightly above the ground so it can’t stick into it. Now if you’ll apply this script to the GameObject and you’ll run the scene, the debug console is telling you False and True. If you collapse the console output you see that False and True are added at nearly the same time, which means for me, in the same frame (There is only a really short delay)!
Adding a bool wasCalled into the class and checking if the update-method was already called makes the program really laggy, so that’s not a solution.
Also I have no code affecting the script, this is a test script I’m using parallel to my real PlayerController, and yes, the real one is disabled!
[RequireComponent (typeof (CharacterController))]
public class PlayerController2 : MonoBehaviour
{
private CharacterController cc;
private float verticalVelocity = 0;
void Start()
{
this.cc = GetComponent<CharacterController> ();
}
void Update()
{
transform.Rotate (0, Input.GetAxis ("Mouse X") * UserPreferences.mouseSensitivity, 0);
Debug.Log(cc.isGrounded);
if (cc.isGrounded)
{
this.verticalVelocity = 0;
}
else this.verticalVelocity = -1;
this.cc.Move(transform.rotation * new Vector3 (Input.GetAxis ("Horizontal") * 3, this.verticalVelocity,
Input.GetAxis ("Vertical") * 3) * Time.deltaTime);
}
}
I hope anyone could help me,
SOP.