- Home /
This question was
closed Jan 25, 2021 at 03:46 AM by
WryanD for the following reason:
Never fixed it, but found another solution
Question by
WryanD · Jan 20, 2021 at 04:59 PM ·
capsulecolliderhitbox
I need help with my Physics.CheckCapsule command
public float health = 1f;
public float bulletDamage = .5f;
public Transform headCheck;
public Transform bodyCheck;
public float headSize = .5f;
public float bodySize = .5f;
public bool headHit;
public bool bodyHit;
public LayerMask bulletMask;
void Start()
{
headHit = false;
bodyHit = false;
}
void Update()
{
headHit = Physics.CheckSphere(headCheck.position, headSize, bulletMask);
bodyHit = Physics.CheckCapsule(bodyCheck.position, bodySize, bulletMask);
if (headHit)
{
health -= bulletDamage * 2;
}
if(bodyHit)
{
health -= bulletDamage;
}
if(health <= 0.2)
{
}
}
I am trying to create two different colliders, one for the head, and one for the body. My character is a capsule, and the head collider works, but when I do
bodyHit = Physics.CheckCapsule(bodyCheck.position, bodySize, bulletMask);
it always shows an error saying that Unity is not able to convert bodySize to a vector. What do I do, to get this to work? Any suggestions appreciated. Thanks
Comment