i am using a polygon collider to defin object and i check istrigger and a scrippt to thme, but when i check istrigger the objects now are untouchables, for example the player can cross a wall if the player has istrigger checked how i solve that?
Hey cefas,
If you want your player to not be able to pass through the wall, use OnCollisionEnter(Collision collision) instead of OnTriggerEnter(Collider collider). Also when you switch to OnCollision, make sure to uncheck the istrigger button.
Hope that helps!
not work u.u the script id no ejecuted when i use it as oncollionenter
this is my script
public void Damage(int damageCount)
{
hp -= damageCount;
if (hp <= 0)
{
// Dead!
Destroy(gameObject);
}
}
void OnTriggerEnter2D(Collider2D otherCollider)
{
atackscript atack= otherCollider.gameObject.GetComponent();
if (atack!= null)
{
if (shot.EnemyAtack!= isEnemy)
{
Damage(atack.damage);
}
}
}
if there is other than OnCollisionEnter,I have seen say that a kind of keys or something like that are used and assigned to the object and if that key ek object has run the script method