https://playcanvas.com/project/1401542/overview/horror
I need to make it so that when an entity touches you, you die
https://playcanvas.com/project/1401542/overview/horror
I need to make it so that when an entity touches you, you die
Hi @dalton_him and welcome!
I noticed you’re using my Basic enemy AI template. It already includes some preparation for bullet hit detection. In the player script, there’s a setHealth() function where you can make the player die instantly if desired. You can create the same function in your own player script as well.
To ensure everything’s working properly, compare your setup with the example project. It looks like the enemy script has currently some unsaved changes.
I tried that but when it is fired nothing happened so I tried to make a death screen so that when the bullet hits me it goes to that and I respawn in a certain place but I couldn’t get that to work so I turn to chat gpt to help me but I kept getting errors so I tried to make it so that if the enemy collides with the player it goes to that death screen and respawn point but I cannot get it to work and because I have very limited coding skills I turn to chat gpt again but it still wont work and is a complete mess. sorry
I just checked your project again and noticed that you’re using the triggerenter event. This event only works on trigger entities without a rigidbody. Since both your enemy and player have a rigidbody, the triggerenter event won’t be fired.
To fix this, you should use the collisionstart event in the initialize function of your script instead.
For more information about collisions and triggers, you can check the page below.
what i decided to do is I just restarted on the script so i took your ai and started there and from there I made the bullet kill you I don’t know why I couldn’t get it to work the first time but it works now but when I try to use animation and the ai it breaches.
What is the current result?
Make sure you only use the Anim component (not the Animation component) and attach your animations to the correct slots. Also, make sure the animations are suitable for your model.