I want to turn on a triggerenter collision volume that will only effect ‘enemies’
Essentially if I press a button, it will enable the trigger volume and if an ‘enemy’ is in the trigger volume when I turn it on, they will die or whatever.
I don’t want this to affect any other object or entity. Just the specific one.
What i’ve tried is code like this but it doesn’t work. Help please
Hi @Robotpencil, you mentioned you found a solution to this, can I ask what workaround you did? I wanna affect specific entity only when entering a trigger volume but it ends up affecting all objects that are entering. thanks.
Yes, I already added a tag, and checked using if(result.other.tags.has('enemy')){} or if(result.other.tags.has('enemy') === true){}; but it gives me an error “Cannot read property ‘tags’ of undefined”. Should I explain my situation here or create another post for it?
Ah okay, I think you have to remove other indeed, because this is only used with onCollisionStart and not with onTriggerEnter. Can you try the way below? Otherwise can you share a link of your project please?
This is as expected because you use a collisionstart event. If your don’t want to use a rigidbody you need to use a triggerenter event (without other). Please check the page below.
I do also have triggerenter, making a screen pop up when entered. But I need also the player to play an animation and this.entity.play(‘chuckHurt’); does not work on my triggerVolume script.
I don’t see where you use this in your triggerVolume script(s). I only see you use this in the player script with a collisionstart event. This will only work if the other entity has a rigidbody too. You need to use triggerenter if the other entity doesn’t has a rigidbody.
Because in this case this.entity is the trigger entity and not the player entity. I suggest to replace this.entity with result, because result is the player entity, which has the sprite.