[En & Fr] Show a message on the screen - Faire apparaître un message sur l’écran


Hello, I am creating a game and I would like to know how to make a temporary message that will be displayed like a screen like “This box is empty” or “You do not have the green key”, which would be displayed only seconds. To be more precise I would like me to approach a GameObject (Cube, Sphere, …) is that I collide with him a temporary message appearing in the middle of the screen with written, as an example “No interaction possible”. I would also like to have the script in C # version otherwise the java script Unity will do the job :)! Thank you and good day.


Bonjour, Je suis en cour de création d’un jeu et j’aimerais savoir comment faire un message temporaire qui s’afficherai a l’écran comme par exemple “Cette boîte est vide” ou " Vous n’avez pas la clé verte", qui s’afficherais que quelque secondes. Pour être plus précis j’aimerais que quand je m’approche d’un GameObject (Cube, Sphère, …) est que je rentre en collision avec lui un message temporaire apparaisse au milieu de l’écran avec écrit, comme exemple “Pas d’interaction possible”. J’aimerais aussi avoir le script en version C# sinon le Unity java script fera l’affaire :slight_smile: ! Merci et bonne journée.

All you need to do is create a generic canvas and add a text box. Make the canvas available to all items, by adding a reference to it, then in the item, where you handle the collisions, call a co-routine where you enable the canvas, set the text, then wait for x seconds, before disabling the canvas.

This works for when you will only have one message on screen at a time. If you need a message box for each item, then simply create a canvas in each object then enable and disable this.


public Canvas message;

void OnCollision()

co-routine MessageAlert()
message.messagebox.text = "Get Off My Lawn";
yield return waitforseconds(2f);