Can anyone explicitly typecasting this for me to use it as referance. This is rigidcontroller.js. file. Error at ‘height’ and ‘radius’ when I try to build on Android
height is a member of CapsuleCollider. But the generic property collider is of type Collider. You have to cast it to CapsuleCollider prior to accessing its variables.
In C#, you would do:
void Awake()
{
// ...
CapsuleCollider capsule = (CapsuleCollider) collider;
// or even safier
CapsuleCollider capsule = GetComponent<CapsuleCollider>();
// then check it, and access it
if (capsule)
{
rayDistance = collider.height * 0.5f + collider.radius;
}
}
So in UnityScript it should look like:
function Awake()
{
// ...
var capsule : CapsuleCollider = collider as CapsuleCollider;
// or even safier
var capsule : CapsuleCollider = GetComponent.<CapsuleCollider>();
// then check it, and access it
if (capsule)
{
rayDistance = collider.height * .5 + collider.radius;
}
}
Note: only one of the alternative to get the component.