Title says it all, the projectiles only hit the player and disappear if the player is standing still, if he is moving, the player will ''jump'' on top of the bullets and walk over them, not triggering a collision and not doing anything really.
What Im trying to achieve is that the bullets will passthrough the player, but still detect collision if they do collide with the player, so that the character controller can never walk on them, or they should just collide with the player before the player gets the chance to walk over them. This problem has to do with the "Step Offset" function in the character controller component, because when I set it to 0.05 this issue does not happen, but I cant do that because my character needs to be able to walk up stairs or over small ledges.
Thanks a lot!
void OnCollisionEnter(Collision other)
{
if (other.gameObject.CompareTag("Player"))
{
scrCh = other.gameObject.GetComponent<scr_CharacterController>();
calculatedDamage = Random.Range(minDamage, maxDamage);
if (scrCh != null && scrCh.currentHealth > 0)
{
CancelInvoke("Remove");
gameObject.SetActive(false);
scrCh.TakeDamage(calculatedDamage);
if (gameObject.CompareTag("Special Bullet"))
{
scrCh.TakeDamage(calculatedDamage * 3);
gameObject.SetActive(false);
}
}
}
if (other.gameObject.CompareTag("Unbreakable"))
{
gameObject.SetActive(false);
}
}