I’m given a null reference exeption error here rayDistance = controller.height * .5 + controller.radius; which results in this error
at this line here
if (Physics.Raycast(myTransform.position, -Vector3.up, hit, rayDistance))
Which makes no sense to me i mean there is no reson in my eyes why this would be zero as if it isn’t picking up the character controller or the params inside it.
the effected code is this can anybody see where the problem might be?
private var rayDistance : float;
private var controller : CharacterController;
private var myTransform : Transform;
private var hit : RaycastHit;
function Start ()
{
myTransform = transform;
rayDistance = controller.height * .5 + controller.radius;
controller = GetComponent(CharacterController);
}
if (Physics.Raycast(myTransform.position, -Vector3.up, hit, rayDistance))
{
{