For anyone that tried this code but the text wouldnt appear even though there is no error, the fix is check if your First Person Controller has a tag of "Player" or not (top right corner of inspector). Hope this helps!
FIGURED IT OUT. THIS IS WHAT YOU NEED TO DO: 1. In your hierarchy, select your Canvas we made in this tutorial 2. Go into the inspector, and find the Canvas panel within the Canvas 3. Go to the Render Mode panel, and set it "Screen Space - Camera" 4. In the same panel, set the Render Camera as your main player camera. In my case, it is found at XR Origin -> Camera Offset -> Main Camera. Just drag your Camera in your heirarchy directly into the Render Camera box. This should fix it. This will make the text display directly in the player's line of sight, and follow their head wherever they move it for 5 seconds.
Hey, I have the code copied exactly, the collider on the box is labelled as a trigger, and i have the player set as a player tag, why isnt it showing up?
FIGURED IT OUT. THIS IS WHAT YOU NEED TO DO: 1. In your hierarchy, select your Canvas we made in this tutorial 2. Go into the inspector, and find the Canvas panel within the Canvas 3. Go to the Render Mode panel, and set it "Screen Space - Camera" 4. In the same panel, set the Render Camera as your main player camera. In my case, it is found at XR Origin -> Camera Offset -> Main Camera. Just drag your Camera in your heirarchy directly into the Render Camera box. This should fix it. This will make the text display directly in the player's line of sight, and follow their head wherever they move it for 5 seconds.
December 2022 - FIGURED IT OUT. THIS IS WHAT YOU NEED TO DO IF YOURS DOESN'T WORK: 1. In your hierarchy, select your Canvas we made in this tutorial 2. Go into the inspector, and find the Canvas panel within the Canvas 3. Go to the Render Mode panel, and set it "Screen Space - Camera" 4. In the same panel, set the Render Camera as your main player camera. In my case, it is found at XR Origin -> Camera Offset -> Main Camera. Just drag your Camera in your heirarchy directly into the Render Camera box. This should fix it. This will make the text display directly in the player's line of sight, and follow their head wherever they move it for 5 seconds. Also, if this doesn't work, as another comment said, make sure that your Player in your heirarchy is set to the "Player" tag. This is done in the inspector, top right, under "Layer". This is becuase the script you write in this tutorial only checks for collisions with objects that are tagged "Player" to trigger the text-showing event. Hope this helps!
I'm getting an error. Something like script class can't be found, when I try to add it to a cube, it says it can't because script class can't be found. What does that mean?
There's a comment that says this: For anyone that tried this code but the text wouldnt appear even though there is no error, the fix is check if your First Person Controller has a tag of "Player" or not (top right corner of inspector). Hope this helps!
FIGURED IT OUT. THIS IS WHAT YOU NEED TO DO: 1. In your hierarchy, select your Canvas we made in this tutorial 2. Go into the inspector, and find the Canvas panel within the Canvas 3. Go to the Render Mode panel, and set it "Screen Space - Camera" 4. In the same panel, set the Render Camera as your main player camera. In my case, it is found at XR Origin -> Camera Offset -> Main Camera. Just drag your Camera in your heirarchy directly into the Render Camera box. This should fix it. This will make the text display directly in the player's line of sight, and follow their head wherever they move it for 5 seconds.
delete the last 2 lines of his code and replace it with uiObject.SetActive(false); you only write this once. so it's supposed to be: IEnumerator WaitForSec() { yield return new WaitForSeconds(5); uiObject.SetActive(false); } }
For anyone that tried this code but the text wouldnt appear even though there is no error, the fix is check if your First Person Controller has a tag of "Player" or not (top right corner of inspector). Hope this helps!
None of these trigger scripts on RUclips are working for me! Can you help? There are no compiling errors or anything, just the text not popping up
Same here
Btw do you already know the problem now?
FIGURED IT OUT. THIS IS WHAT YOU NEED TO DO:
1. In your hierarchy, select your Canvas we made in this tutorial
2. Go into the inspector, and find the Canvas panel within the Canvas
3. Go to the Render Mode panel, and set it "Screen Space - Camera"
4. In the same panel, set the Render Camera as your main player camera. In my case, it is found at XR Origin -> Camera Offset -> Main Camera. Just drag your Camera in your heirarchy directly into the Render Camera box.
This should fix it. This will make the text display directly in the player's line of sight, and follow their head wherever they move it for 5 seconds.
What changes do I need to make in order to have the text not destroy after the player steps in the trigger?
Hey, I have the code copied exactly, the collider on the box is labelled as a trigger, and i have the player set as a player tag, why isnt it showing up?
FIGURED IT OUT. THIS IS WHAT YOU NEED TO DO:
1. In your hierarchy, select your Canvas we made in this tutorial
2. Go into the inspector, and find the Canvas panel within the Canvas
3. Go to the Render Mode panel, and set it "Screen Space - Camera"
4. In the same panel, set the Render Camera as your main player camera. In my case, it is found at XR Origin -> Camera Offset -> Main Camera. Just drag your Camera in your heirarchy directly into the Render Camera box.
This should fix it. This will make the text display directly in the player's line of sight, and follow their head wherever they move it for 5 seconds.
December 2022 - FIGURED IT OUT. THIS IS WHAT YOU NEED TO DO IF YOURS DOESN'T WORK:
1. In your hierarchy, select your Canvas we made in this tutorial
2. Go into the inspector, and find the Canvas panel within the Canvas
3. Go to the Render Mode panel, and set it "Screen Space - Camera"
4. In the same panel, set the Render Camera as your main player camera. In my case, it is found at XR Origin -> Camera Offset -> Main Camera. Just drag your Camera in your heirarchy directly into the Render Camera box.
This should fix it. This will make the text display directly in the player's line of sight, and follow their head wherever they move it for 5 seconds.
Also, if this doesn't work, as another comment said, make sure that your Player in your heirarchy is set to the "Player" tag. This is done in the inspector, top right, under "Layer". This is becuase the script you write in this tutorial only checks for collisions with objects that are tagged "Player" to trigger the text-showing event. Hope this helps!
I'm getting an error. Something like script class can't be found, when I try to add it to a cube, it says it can't because script class can't be found. What does that mean?
Even though i put the code right and insert the text into the code, why the text doesn't pop up? I hope you can reply, thank you!
There's a comment that says this: For anyone that tried this code but the text wouldnt appear even though there is no error, the fix is check if your First Person Controller has a tag of "Player" or not (top right corner of inspector). Hope this helps!
FIGURED IT OUT. THIS IS WHAT YOU NEED TO DO:
1. In your hierarchy, select your Canvas we made in this tutorial
2. Go into the inspector, and find the Canvas panel within the Canvas
3. Go to the Render Mode panel, and set it "Screen Space - Camera"
4. In the same panel, set the Render Camera as your main player camera. In my case, it is found at XR Origin -> Camera Offset -> Main Camera. Just drag your Camera in your heirarchy directly into the Render Camera box.
This should fix it. This will make the text display directly in the player's line of sight, and follow their head wherever they move it for 5 seconds.
Thank you for this very helpful video and script :D
Hi
How do I stop the text from following the player?
If you want your text to stay in a certain location, don’t use a canvas and just add the text and you can move it to where you want it.
Thank you so much! Super helpful :)
very nice tutorial thank amar:D
Can you tell how can I display the text everytime I enter the area ? I don't want it to disappear after displaying once
just dont have destroy gameobject and waitforseconds
so that means you wont need to do the ienumorator and the last part of the void on trigger enter
delete the last 2 lines of his code and replace it with uiObject.SetActive(false);
you only write this once. so it's supposed to be:
IEnumerator WaitForSec()
{
yield return new WaitForSeconds(5);
uiObject.SetActive(false);
}
}
You are a LEGEND THANK YOU
Very helpful, thank you so much !
Thank you
please i beg get a mic