Hi! I wonder if there's a way to trigger event upon collision from npc, meaning the event will be triggered when the npc collides with the player (not the opposite).
There's a few example in my game that needed this:
1. Some npc running around, and when player gets close they will start chasing the player. When they hit the player some dialogue will appear.
2. Some npc walking in a fixed direction, and if the player walks into their path and blocks their way, event will trigger upon collision between npc and player like npc saying 'stop blocking my way' and stuff.
Thanks!
You can have enemies chase using hunting in Move AI which you can look up in the tutorial.
Yes, I am using hunt Move AI, but I'm finding a way to start an event when the npc collides the player from behind. Because the event interaction controller for the player is placed in front of him, and when something collides him from the back it doesn't trigger the event. (event interaction script component is placed on the npc, not the player, as different npc has different event interaction).
Currently, the npc is able to hunt the player, but when it collides with the player, nothing happens unless the npc is in front of the player (due to the event interaction controller being placed in front of the player).
Is there a solution for this?
Collision/trigger start types don't need the interaction controller, since the IC is only used for Interact start type (i.e. you can interact with events that are within the IC). Try enabling Start By Root Object, as you might be colliding with some child object of the player :)
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
This is the component attached to the npc. The event will start between 2 actors, which is player and event object.
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
1. When I use Collision Enter start type, nothing occurs no matter how I collide with the npc. Both of them have a rigidbody component and capsule collider attached to them. I suspect it is due to me having the move AI to stop before colliding the player when chasing him (for a very short distance), which causes the collider to not collide with each other. Unchecking or checking start by root object doesn't make a difference here.
2. When I tried using Trigger Enter start type, I realized the npc will only react to the interaction controller attached in front of the player. I tried moving the controller around during in game and it was true, the npc with the event interaction attached only react to the interaction controller component.
How do I solve this? I want the event to be triggered when the npc bump into the player, no matter from which direction.
Apparently, I found out that Trigger Enter is the one I need, and it is reacting to the box collider (with trigger) attached to the interaction controller. (collision enter start type gives no reaction at all) Knowing this, I attached a box collider on the player with trigger checked and checked start by root object. It worked! The npc reacted once it enters the box collider area.
Thanks for everyone that commented!