- Home /
The question is answered, right answer was accepted
BCE0019: 'height' is not a member of 'UnityEngine.Collider'.
Error at 'height' and 'radius'
@script RequireComponent(Rigidbody, CapsuleCollider)
function Awake (){
rigidbody.freezeRotation = true;
rigidbody.useGravity = false;
myTransform = transform;
mainCameraGO = gameObject.FindWithTag("MainCamera");
weaponCameraGO = gameObject.FindWithTag("WeaponCamera");
rayDistance = collider.height * .5 + collider.radius;
playerWeapons.animation.wrapMode = WrapMode.Loop;
}
Height isn't a member of Collider perhaps it's the member of a particular kind of collider for whichj you would need a cast.
(collider as SphereCollider)
no, this should work with a capsule collider.. is it possible there is another collider on the object as well?
Answer by ScroodgeM · Jul 24, 2012 at 11:23 AM
@script RequireComponent(Rigidbody, CapsuleCollider)
function Awake (){
rigidbody.freezeRotation = true;
rigidbody.useGravity = false;
myTransform = transform;
mainCameraGO = gameObject.FindWithTag("MainCamera");
weaponCameraGO = gameObject.FindWithTag("WeaponCamera");
var sphereCollider = gameObject.GetComponent(CapsuleCollider);
rayDistance = sphereCollider.height * .5 + sphereCollider.radius;
playerWeapons.animation.wrapMode = WrapMode.Loop;
}
Changing the script I got BCE0005: $$anonymous$$ identifier: 'sphereCollider'.
type 'var' before variable. i'd fix answer. don't like JS.
Answer by Seth-Bergman · Jul 22, 2012 at 10:04 AM
try explicitly typecasting it:
var myCollider = gameObject.GetComponent(CapsuleCollider);
myCollider.height... etc.
oh and please don't use answer field for comments
Sorry Seth, it doesn't work for me, I am getting BCE0019: 'mycollider' is not a member of 'UnityEngine.GameObject'.
Perhaps you should construct a new question. The error code is the same but your case is different.