FIRST PERSON INTERACTION in Unity!
ฝัง
- เผยแพร่เมื่อ 12 ก.ย. 2024
- In this tutorial we'll learn how to make an interaction system for first person games!
LINKS
Starter Project:
github.com/tda...
Outline asset:
assetstore.uni...
Simple Items Pack:
assetstore.uni...
Patreon:
/ kabungus
Thank you very much for this tutorial, it saved me a lot of time on my final project as the previous tutorial made me having a problem with the outline working only after clicking for the first time in an object
Great vid! Just wanted to give some feedback; first off the original approach was okay, i would recommend using an IInteractable interface and checking with the component instead of the tag. Also cache that camera!!
I would also recommend instead of enabling the outline i would add an OnBecameInteractable event and method onto the interface or in your case the class in case i want to do more than just showing/hiding an outline. Same for when its no longer interactable. Just a couple things that came to mind while watching.
So... let's say nothing works on my end. What's the procedure?...
thanks for this but it would really help to explain the lines of code more thoroughly (just like you did for the if statements), more like explaining the logic behind each line in more of a beginner friendly manner. wish you the best
Well all he did was first create a script called Interactable (You will need to add this script to every single thing you wish to interact with in the game.) This script also contains a message which you will see when you go near it and a UnityEvent (Here in the inspector you attach the function which you wish to run when someone actually presses the interact button) basically what happens when someone interacts with your interactable. for a light switch you will attach the function which turns on the light.
Then we create a new script called Player Interaction. This script is responsible for actually interacting with the object. Here we just shoot an imaginary line from the center of our screen (called a ray) and if that line hits the interactable object then we know that this is the object we need to interact with.
Ofcourse there is more to this but this is the basic outline of the video.
Let me know if this helps.
Very nice video man! THX
Make more videos like this... I'm gonna support you man....
You best man, thank you very well
good work lad
There is also a problem, if there is no collider, then the outline will be enabled until you collide with another object that has a collider, for that make sure to place a cube in your camera and place it on top of the raycast. that will solve the problem; xD edit: of course a collider which has another tag to make sure your script has "else{ disableOutline }"
I really liked the Tutorial and therefore I subscribed. Thanks for really great video.
i love how the links in his description are entirely unusable
i did the exact same script and doesn't let me change anything in unity :')
Amazing Thanks~
Good content broo awsome ❤
can it play a door animation
is it just me or did he just jinx me with only giving me the interact script then telling me to place another script that "we" aprenetly made
Where is Outline script from?
I think it’s a component
hello, may I ask for the project?
What does the error "The type or namespace name 'interactable' could not be found (are you missing a using directive or an assembly reference?)" mean?
You renamed or misspelled the script name or the class name (the thing before : MonoBehaviour). In the video the script name is capitalized so maybe check if your Script/Class is called Interactable and not interactable.