Skip to main content
Tweeted twitter.com/StackGameDev/status/695213411060289536
added 93 characters in body; edited tags
Source Link
MAnd
  • 4.9k
  • 3
  • 25
  • 43

ImI am making a melee attack with my game, but ImI'm stuck in a problem related to using triggers. My AIThe enemy NPCs have a sphere collider set on trigger so I will know who is inside histheir range ( radiusradius of 15).

Then, then a madeI wrote a simple OnTriggerEnter script to make that when my sword (theits collider is set to trigger as well, so it will pass through the enemy) hits an enemy NPC, it will destroy thethat enemy, but. The problem is that when I try to test it, the enemyenemies are destroydestroyed once I enter thetheir sphere collider. 

So, is there a way to ignore the trigger from their shpere collider? Or what is the best way to do a melee attack?

NOTE: the destroy function is public in the enemy script and it was called in weapon script attached to the weapon.

Im making a melee attack with my game but Im stuck in triggers. My AI have sphere collider set on trigger so I will know who is inside his range ( radius of 15), then a made a simple OnTriggerEnter script that when my sword (the collider is set to trigger so it will pass through the enemy) it will destroy the enemy, but when I try to test it, the enemy are destroy once I enter the sphere collider. So, is there a way to ignore the trigger from shpere collider? Or what is the best way to do a melee attack?

NOTE: the destroy function is public in the enemy script and it was called in weapon script attached to the weapon.

I am making a melee attack with my game, but I'm stuck in a problem related to using triggers. The enemy NPCs have a sphere collider set on trigger so I will know who is inside their range (radius of 15).

Then, I wrote a simple OnTriggerEnter script to make that when my sword (its collider is set to trigger as well, so it will pass through the enemy) hits an enemy NPC, it will destroy that enemy. The problem is that when I test it, the enemies are destroyed once I enter their sphere collider. 

So, is there a way to ignore the trigger from their shpere collider? Or what is the best way to do a melee attack?

NOTE: the destroy function is public in the enemy script and it was called in weapon script attached to the weapon.

Source Link

Problem with trigger

Im making a melee attack with my game but Im stuck in triggers. My AI have sphere collider set on trigger so I will know who is inside his range ( radius of 15), then a made a simple OnTriggerEnter script that when my sword (the collider is set to trigger so it will pass through the enemy) it will destroy the enemy, but when I try to test it, the enemy are destroy once I enter the sphere collider. So, is there a way to ignore the trigger from shpere collider? Or what is the best way to do a melee attack?

NOTE: the destroy function is public in the enemy script and it was called in weapon script attached to the weapon.