How would one go about creating such a script to notify a player if a grenade is close and ready to explode.
A trigger collider would probably work well here, create a sphere collider around the player and then have it search for a grenade tag perhaps, for the grenade icon like you see in multiplayer shooters you could make use of the worldspace canvas and attach that to the grenade object itself and have it activate when grenade enters the sphere. You could have the worldspace canvas attached to the grenade constantly and just hide it until it’s needed and then it will destroy itself along with the genade gameobject after it’s done exploding because it will be a child of the grenade gameobject.
Check out collider and activation tutorials for how to do it.
Here’s a worldpsace canvas tutorial too.
If you want to just simply flash a text message up, then you won’t need worldspace and can simply activate the text when the collider is triggered.
as an extension once you’ve got the basic premise working; you might consider an Interface so you can use the same setup to handle any “threats”, grenades/bombs/environmentalEffects/whatever.
Thank you very much. You guys will be given credit in the game.
Sorry i loged in wrong account there. ![]()