Тёмный

How to make an Interaction Feature (Unity Tutorial) 

JTAGames
Подписаться 9 тыс.
Просмотров 35 тыс.
50% 1

Project Files available now on Patreon for our patrons!
/ jtagamesinc
JTAGames is unfortunately closing it's doors. Jon-Tyrell (The guy who's voice you hear 90% of the time) is moving to "Keahunui Technologies" An unofficial company / branding owned exclusively by himself.
Thank you for your support the tutorials will remain on this channel.
Please wishlist Keahunui technologie's first game on steam!
store.steampowered.com/app/15...
If you're feeling super supportive of Keahunui Technologies consider checking out Kickstarter.
www.kickstarter.com/projects/...

Игры

Опубликовано:

 

22 апр 2021

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 146   
@EmilJoes
@EmilJoes 2 года назад
Super effective and flexible way to make interaction systems instead of having a lot of different scripts with different rays sending out to different things. Thanks for the tutorial :)
@ruhitrai6015
@ruhitrai6015 2 года назад
How it efficient bro ? It using update method each frame
@jolinanturis3166
@jolinanturis3166 Год назад
@@ruhitrai6015 How is it gonna work? To make the script work, you'll need the update function, sure not the most effective, but still more effective than well making millions of scripts for different things.
@chanrachael4628
@chanrachael4628 2 года назад
I'm beginner and I totally understand, thank you so much for the great tutorial
@TheWobiz
@TheWobiz 3 года назад
Really nice tutorial! straight to the point, i would love more tutorials about Horror Games
@JTAGames
@JTAGames 3 года назад
Our goal is to waste as little of your time as possible so you can get back to developing. Anything specific in mind for horror game tutorials?
@TheWobiz
@TheWobiz 3 года назад
@@JTAGames I would love something like reading notes, flashlight, Keys or codelocks, following Ai, everything would help! 😊
@harry6270
@harry6270 2 года назад
Great tutorial! I learned a lot.
@markflakezCG
@markflakezCG Год назад
Thanks! I'm a beginner and made it first with colliders but that was not good at all. Now it feels good.
@khurum
@khurum 8 месяцев назад
this is so easy I watched a ton of videos but none explained like that many thanks
@BigToeDev
@BigToeDev 2 года назад
Great tutorial man! Clear and straight to the point! Thanks for helping us out :D
@ferdinandw.8952
@ferdinandw.8952 Год назад
What are you doin here?
@warehouse1292
@warehouse1292 Год назад
1000th Subscriber
@shaheentechnologies4649
@shaheentechnologies4649 2 года назад
You earn my sub
@ParsTajicAfghan
@ParsTajicAfghan 5 месяцев назад
thank you best tutorial i have
@omengaming2019
@omengaming2019 2 года назад
Awsome sir!
@AndreaLPM1
@AndreaLPM1 3 года назад
Nice tutorial and very helpful. Question: What would be the best to manage lets 100 interactable objects?
@JTAGames
@JTAGames 3 года назад
This method works fine for 100+, probably even 1000+ I've already used a less refined version in a commercial game with 100+ interactables a while back. store.steampowered.com/app/1382180/Escape_Knox_Manor/ What's cool is that each interactable doesn't actually do anything they just store information and the interactor script does all the work, along with Unity's event system. you'll be limited by having too many game objects with mesh colliders long before interactables slow you down. Let me know if you have any other questions!
@AndreaLPM1
@AndreaLPM1 3 года назад
@@JTAGames Thanks for your answer and the example ahah ! Keep on with this yt channel.
@BERKACE
@BERKACE 2 года назад
I'd love to see a tutorial using this system on a typical walking simulator mechanic: a paper that you can click on and then have it pop up on the screen so the player can read it
@JTAGames
@JTAGames 2 года назад
I might do this a RU-vid short
@suitNtie22
@suitNtie22 2 года назад
How would I make a bool Toggleable in this? Like say if I want an object to toggle between two materials every time I click on it?
@mostafamo1315
@mostafamo1315 Год назад
How would u write the code if i want to select the game object and rotate it then deselect it and it goes back to place
@SubscribeToRomanianRays
@SubscribeToRomanianRays Год назад
Hi, how would I make this work in 2d? What do I put the Interactor script on?
@himiko4202
@himiko4202 2 года назад
After adding the first interactor script to my camera to test it, my game just no longer starts unless i remove the script. Edit: I fixed it, i'm not sure why it didnt work exactly but i edited the code to basically say the same thing but in a different way. void Update() { var ray = new Ray(this.transform.position, this.transform.forward); RaycastHit hit; if (Physics.Raycast(ray, out hit, 50, interactableLayermask)) { Debug.Log(hit.collider.name); }
@heyreefes
@heyreefes 3 года назад
damn this good
@estusmedia1887
@estusmedia1887 2 года назад
Hi, is there any way you can make this project downloadable at all? At times you cover things without actually explaining how it is set up, for example the door frame already having an animator, having different animation states such as Opened and Closed, and also the sprites setup. I managed to get the sprites setup working but animation is something I struggle with and either a clearer breakdown of how this was all set up or access to the project folder would really be helpful.
@JTAGames
@JTAGames 2 года назад
Projects not for download but when I have time I can make a tutorial tackeling animation and animators with this set up as the example.
@darkdoom907
@darkdoom907 2 года назад
How is the animator controller setup, can someone please tell
@Marcieman
@Marcieman Год назад
Thanks got it sort of working but am left with the animation as certain stuff is not explained and missing which makes this tutorial frustrating. Text size to resolution is just too low; have to go to full screen to read the text. Code is shown for a really short time and sped up a lot. Somewhere we had to write code and delete it one moment later without any reason why we wrote it in the first place (I dont mean the unity events or the logs). "Just simply put in the animator we made", which animator we made? Nowhere to be found, let alone the sprites which are also referenced to as that 'we' made it earlier in the tutorial, which we didn't... I think I am missing some sort of other part that goes beforehand. Sorry for my rant, not a personal attack as I do appreciate that you took the time to explain this! For anyone else to keep them from getting frustrated; here is the code. Forgot to mention anyone else reading; you have to make a Canvas and create a new object called 'image' in order to add the image in Interactable (also missed out on explaining that).
@JTAGames
@JTAGames Год назад
Animation was not apart of the tutorial. It was just the interaction. Also what text size?
@FortressVOfficial
@FortressVOfficial Год назад
4:55 leaving a mark
@v-rdays7525
@v-rdays7525 3 года назад
Can you make tutorial like this but in blueprints Bolt,something like this
@JTAGames
@JTAGames 3 года назад
Ive got to learn bolt first lol. Yeah I'll look into it. It might be a while though.
@supersentaimexicano1967
@supersentaimexicano1967 Год назад
For future tutorial videos it would be hugely apreciate if u show not only the code but also the setup of the scene. I got lost a lot when I had to asign images and sprites to the project.
@emptydeletions
@emptydeletions 2 года назад
Why don't i have Canvas, EventSystem, InteractIcon in the Hierarchy? And why am i getting "NullReferenceException: Object reference not set to an instance of an object Interactor.Update () (at Assets/Scripts/Interactor.cs:58)" i have MainCamera Tag on my main camera and i have no errors in the scripts but still im getting this when a run the game.
@JTAGames
@JTAGames 2 года назад
You need to create the canvas /interact image yourself
@emptydeletions
@emptydeletions 2 года назад
@@JTAGames thanks alot for the super quick response and help after adding canvas with interaction image and adding it in the camera interact image it all worked thanks alot
@TatsukiBaba
@TatsukiBaba 2 года назад
how to make a crosshair pick up items
@antonzhavner1750
@antonzhavner1750 2 года назад
Cool friend. Your channel is excellent. I am still a beginner. Is this system suitable for mobiles?
@JTAGames
@JTAGames 2 года назад
Yes! Follow this tutorial first then follow our most recent mobile control tutorial and at 8:46 in the mobile control video It shows you how to combine this with the mobile controls.
@antonzhavner1750
@antonzhavner1750 2 года назад
@@JTAGames thanks👍
@reactivedevelopment6768
@reactivedevelopment6768 3 года назад
For the Game Jam can we modify some of the code or does it have to be the same as the tutorial
@JTAGames
@JTAGames 3 года назад
It can be modified! As long as it's recognizable as being from this tutorial you'll be fine. So pretty much a raycast using unity events. Get creative! I'm excited to see what you come up with.
@reactivedevelopment6768
@reactivedevelopment6768 3 года назад
@@JTAGamesok thx
@netherite5974
@netherite5974 Год назад
how to open door with a key if you have key
@cecavacd
@cecavacd 2 года назад
How do I do it with tmp text? Instead of images I want to add text.
@JTAGames
@JTAGames 2 года назад
It’s essentially the same but I would recommend keeping the image function and beneath it have a tmp text ui reference and a public string on on the interactable that changes that ui text and have it turn off and on at the same time as the image. Hope that made sense
@Psychopox
@Psychopox Год назад
instead of doing public Text text, do public TMPro text;
@marvicaaronlequin982
@marvicaaronlequin982 2 года назад
Tried to follow the code but it does not help me when it reaches the LayerMasks. I copied the code front and back but it does not do anything for me
@JTAGames
@JTAGames 2 года назад
Have you made the layermasks in the editor? If so are they spelt the same way?
@evangelia941
@evangelia941 Год назад
Great tutorial, however it does not work in my scene. I saw that you have set up a canvas which includes the eventsystem in it...should we all have a canvas in our scene for the script to work?
@JTAGames
@JTAGames Год назад
Yes
@evangelia941
@evangelia941 Год назад
@@JTAGames thank you!! Do you maybe have a tutorial on how to add the canvas etc from the beginning?
@JTAGames
@JTAGames Год назад
@@evangelia941 I do not. However, I can give a brief explination. Right click in the hierarchy, go to UI, and click on image. That will be your interact image. Adjust it's size to your preference. You shouldn't need anything else from UI
@hersonmarco2052
@hersonmarco2052 2 года назад
I made a button with the Interactable script to open a hidden door on the wall When I press this button, the parameter bool "open" toggles to true and the animation plays, but it doesn't actually play. The animator window says that the animation is playing when "open" is true, but in game, none of that is happening. I have no idea what is happening
@JTAGames
@JTAGames 2 года назад
Is the door set to static?
@hersonmarco2052
@hersonmarco2052 2 года назад
@@JTAGames yes....... it worked
@JTAGames
@JTAGames 2 года назад
@@hersonmarco2052 Yeah I had the same problem for like 2 hours a few months before I posted this tutorial before I realized static can’t be turned on.
@cepfathir7829
@cepfathir7829 2 года назад
Nice, btw , can you make a interact with outline?
@JTAGames
@JTAGames 2 года назад
What is outline?
@chanrachael4628
@chanrachael4628 2 года назад
@@JTAGames Maybe he means highline object?
@jimking1000
@jimking1000 2 года назад
Can you please explain how you hid the blue sphere? If I turn off mesh render, then the blue sphere doesnt appear after the green sphere has been interacted.
@JTAGames
@JTAGames 2 года назад
When you click on the green sphere 1. Blue sphere : activate game object 2. Green sphere: deactivate game object. When you click on the blue sphere 1. Green sphere: activate game object 2. Blue sphere: deactivate game object. Make sure the events are in that order for the respective spheres
@jimking1000
@jimking1000 2 года назад
@@JTAGames Sorry i must have not been clear, I meant in the first place how did u hide the blue sphere since in the scene tab you couldn't see the sphere at all.
@JTAGames
@JTAGames 2 года назад
@@jimking1000 Okay I think I understand your question but maybe not, we’ll see. It was disabled in the hierarchy
@jimking1000
@jimking1000 2 года назад
@@JTAGames Ohh that makes sense thank you. Last question is it possible to increase the range of when you can interact?
@JTAGames
@JTAGames 2 года назад
@@jimking1000 @1:13 it says out hit, 2… increase or decrease the number in order to increase or decrease the distance.
@mitnick2512
@mitnick2512 Год назад
I love this script and think it works very well, however I've noticed an issue. You can interact with objects through walls, is there any way to fix that?
@JTAGames
@JTAGames Год назад
Put default in the layer mask as well. It shouldn’t break anything since it still checks for the script.
@mitnick2512
@mitnick2512 Год назад
@@JTAGames I had already fixed it but thanks!
@arandomcookie
@arandomcookie Год назад
Hi, I'm back again. How can I call a specific Unity Event using the interaction system?
@JTAGames
@JTAGames Год назад
? By adding it to the interactable? What do you mean?
@arandomcookie
@arandomcookie Год назад
​@@JTAGames I mean like: If you interact with this object, an event is called and other scripts will activate. Another thing is: Is it possible to create a variations in one object? For instance: tapping a button once to turn it on, and tap it a second time to turn it off without using animations? If there's another video of yours that answers any of my questions, I'm sorry for the annoyance. I'm trying to make a game with no knowledge using only youtube videos to program specific parts as I go.
@JTAGames
@JTAGames Год назад
@@arandomcookie The script already does exactly what you’re asking. It does the same thing as setting up a button. To have different results I’d recommend using bools or iterating through events. Also I’d recommend reading documentation on Unity Events because using this as a method for interaction will take forever if you don’t have a firm grasp of Unity Events.
@arandomcookie
@arandomcookie Год назад
@@JTAGames Ok! Thank you very much!
@timewastingenjoyer
@timewastingenjoyer Год назад
Is there a way to use this system to transition the player between scenes?
@JTAGames
@JTAGames Год назад
Yup! We have a scene change tutorial and you can call the scene change function via interact as opposed to having it triggered when you enter in the trigger
@timewastingenjoyer
@timewastingenjoyer Год назад
@@JTAGames thanks!
@timewastingenjoyer
@timewastingenjoyer Год назад
@@JTAGames The only problem I'm having with this is that I'm exiting the doors at the wrong angle, is there a way to rotate the player either just before or just after using the door?
@vitominiello6561
@vitominiello6561 Год назад
how can I add a cursor in my scene? As soon as you start the program, you can already see the cursor, how can I add one into my scene?
@JTAGames
@JTAGames Год назад
UI image center of the screen.
@vitominiello6561
@vitominiello6561 Год назад
@@JTAGames it’s as simple as that? But if my camera moves, the cursor won’t follow it right?
@JTAGames
@JTAGames Год назад
@@vitominiello6561 UI isn’t actually in your game scene it only renders to the spot it’s at on the screen. Even if you don’t have a camera in the scene it’ll render. That being said it won’t work without the camera. But no it won’t move unless you change its settings.
@vitominiello6561
@vitominiello6561 Год назад
@@JTAGames ok thank you really much!
@mariegrasmeier9499
@mariegrasmeier9499 Год назад
Thanks for the tutorial, looks great. I tried it with the Unity Starter Assets First Person Controller and it does not work. I tried the interactor script on the Main Camera, the PlayerFollowCamera and the Player Camera Root. Did not help. Guess the problem is here: if(Physics.Raycast(this.transform.position,this.transform.forward,out hit, 2, interactableLayermask)) { Debug.Log(hit.collider.name); } Can anyone help?
@mariegrasmeier9499
@mariegrasmeier9499 Год назад
Now it works. The problem was that the distance = 2 was too small. Always check the scale of your world.
@evangelia941
@evangelia941 Год назад
thank you for this, mine does not work either, what distance you changed it to?
@mariegrasmeier9499
@mariegrasmeier9499 Год назад
@@evangelia941 In my case, I think I changed to 10. But it always depends on the scale of everything. In the end, you must play around with the values until it work. You could use this debug tool to draw a line and make the ray visible, so you will see where it hits (sorry, forgot the exact way to do it. It is like "Debug.Log" but something else instead of "Log"
@Rokyloreq
@Rokyloreq 2 года назад
Nice video but can you give us the interaction hand?
@JTAGames
@JTAGames 2 года назад
Sure. I'm working on a website and it's no where close to being ready but I can put the UI asset there for free. I'll comment here when it's up. EDIT: jtagamesinfo.wixsite.com/jtagames This is the beginning of the website we're working on. If you want the hand Icon just go to "Assets" page and click download you'll get a zip file with the single PNG.
@gemivr
@gemivr 2 года назад
Can I have a link to get the code from
@JTAGames
@JTAGames Год назад
www.patreon.com/JTAGamesInc Project files to this tutorial and eventually all of our tutorials are available to our patrons on Patreon.
@RoxosonRx
@RoxosonRx 2 года назад
NullReferenceException: Object reference not set to an instance of an object Interaction.Update () (at Assets/scripts/Interaction.cs:18) if (Physics.Raycast(Camera.main.transform.position,Camera.main.transform.forward, out hit,2,Interaction)) how to repair this?
@Delicious_Crystal
@Delicious_Crystal 2 года назад
make sure whatever camera you are using is tagged as MainCamera.
@infinityboss7239
@infinityboss7239 2 года назад
@@Delicious_Crystal Thanks
@communistdoggo3804
@communistdoggo3804 2 года назад
@@Delicious_Crystal Thanks man
@audunstolpe7408
@audunstolpe7408 2 года назад
Nice Tutorial. Im having some issues related to the project structure and how to assign the interact icon. Any chance for a link to the code?
@JTAGames
@JTAGames 2 года назад
Codes not your problem. Drag and drop the image into the inspector.
@bangagus1703
@bangagus1703 2 года назад
Can you make examine object tutorial?
@JTAGames
@JTAGames 2 года назад
Like holding the object mid air and rotating it?
@bangagus1703
@bangagus1703 2 года назад
@@JTAGames Yes, like that,I tried to make a system inspact but always failed
@ManMr.
@ManMr. Год назад
Every time I start the game, the animation immediately loops to open and closed without any interaction. Ive got no idea how to fix it
@JTAGames
@JTAGames Год назад
You didn’t set up parameters for your animator.
@ManMr.
@ManMr. Год назад
@@JTAGames Sorry for bothering you again, but I have set up the Open parameter and have the interactible set correctly, but the animation still goes by itself. I am new to all this, so Im probably missing something obvious
@JTAGames
@JTAGames Год назад
@@ManMr. You need to click on the little line on the animator window between your two animations and then then set the BlendTree Parameter to Open, False or Open, True respectively.
@ManMr.
@ManMr. Год назад
@@JTAGames TYSM!
@turtleproductions5900
@turtleproductions5900 Год назад
Can we get the script it is to small to see
@JTAGames
@JTAGames Год назад
www.patreon.com/JTAGamesInc Project files to this tutorial and eventually all of our tutorials are available to our patrons on Patreon.
@darkdoom907
@darkdoom907 2 года назад
I have a problem when I open the door, it gets opened and closes automatically
@JTAGames
@JTAGames 2 года назад
Make sure you set the opposite animation to go when the bool is false and the other when the bool is true. Likely one of them doesn’t have that set up so it just loops back
@darkdoom907
@darkdoom907 2 года назад
@@JTAGames hey, thanks for replying, turns out the problem arises only with input system, I tried it with the old Input System and it works fine. Would u mind helping me with this error?
@JTAGames
@JTAGames 2 года назад
@@darkdoom907 never used the new input system. If I get around to it I’ll let you know 👍 sorry about that
@darkdoom907
@darkdoom907 2 года назад
@@JTAGames Its alright, I already know what's causing the problem, explaining in terms of the old input system, my input when i press down sets the bool to be true, but it also reads input when I release the button which causes the bool to become false, and if I keep holding my input, the door open animation gets triggered for like infinite times
@darkdoom907
@darkdoom907 2 года назад
Update, i just went along with .triggered function of input system and it works fine
@mratech8396
@mratech8396 2 года назад
you type so fast i can follow
@pixelmusic7273
@pixelmusic7273 2 года назад
can I use this for Mobile Phone?
@JTAGames
@JTAGames 2 года назад
With some alterations yeah. I'm working on a tutorial for mobile games and this gets tacked on the end.
@pixelmusic7273
@pixelmusic7273 2 года назад
@@JTAGames thank you
@JTAGames
@JTAGames 2 года назад
@@pixelmusic7273 The tutorial is now posted. Follow that tutorial first and then this one. ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-UkiXp1VzqQo.html&t
@pixelmusic7273
@pixelmusic7273 2 года назад
@@JTAGames thank you soo muchh
@KineticProduction
@KineticProduction 2 года назад
i want to interacted object for android like granny games
@JTAGames
@JTAGames 2 года назад
Don’t know what granny games is but this works for mobile and we have another tutorial for that too! It’s the FP mobile controller video on our channel
@vdzmhm
@vdzmhm Год назад
I'm so confused what the f is a raycast and layermasks?!?!
@JTAGames
@JTAGames Год назад
I’d recommend learning a little more about unity before tackling this tutorial. A raycast is essentially a laser pointer and the red dot holds the information the script needs. Layermask is an ID system and in this case tells the script what the laser pointer can and can’t point at.
@vdzmhm
@vdzmhm Год назад
@@JTAGames oh ok thank you very much!! 😀
@mratech8396
@mratech8396 2 года назад
ur not explaining its hard to follow
@JTAGames
@JTAGames 2 года назад
Try setting the playback speed to .75 the audio will be weird but it should be easier to follow
@arandomcookie
@arandomcookie Год назад
Functioned great until I tried using the Interectable script in multiple objects. It just broke. I can only interact with 1 object that uses the script, the other ones just stop working. @JTAGames, what can I do?
@JTAGames
@JTAGames Год назад
I’ve never had that happen before to be totally honest. Is your interactor script properly switching its current interactable?
@arandomcookie
@arandomcookie Год назад
@@JTAGames I am a firm believer of "Show rather than tell", so I made a quick video showing what is happening. If you can check it out and see if you can find the error, I'd appreciate it. (Please forgive the very rough video, I just want to get this solved as fast as possible) ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-jgQhX0RASRs.html
@arandomcookie
@arandomcookie Год назад
@@JTAGames Happy ending to this whole situation: I re-wrote the entire thing and it works now!
@Daniel-tg3su
@Daniel-tg3su Год назад
InteractIcon & iconSize are bugged, for the interacticon I get this --> 'Interactable' does not contain a definition for 'InteractIcon' and no accessible extension method 'InteractIcon' accepting a first argument of type 'Interactable' could be found (are you missing a using directive or an assembly reference?) I have a Canvas and an InteractIcon in my hierarchie. Here is the piece of code. if (interactable.InteractIcon != null) { interactImage.sprite = interactable.InteractIcon; if (interactable.iconSize == Vector2.zero) { interactImage.rectTransform.sizeDelta = defaultInteractIconSize; } else { interactImage.rectTransform.sizeDelta = interactable.iconSize; } }
@JTAGames
@JTAGames Год назад
Do you have a public sprite called interactIcon in the interactable script?
@Daniel-tg3su
@Daniel-tg3su Год назад
@@JTAGames No I didn't, thank you!
@hannahhoward3402
@hannahhoward3402 2 года назад
I'm getting an error whenever I get within the range to interact with the object, I'm not even interacting with the object just getting close to it. InvalidOperationException: You are trying to read Input using the UnityEngine.Input class, but you have switched active Input handling to Input System package in Player Settings. UnityEngine.Input.GetKeyDown (UnityEngine.KeyCode key) (at :0)
@JTAGames
@JTAGames 2 года назад
You updated your input settings so it’s no longer compatible with with any “Input.get” I haven’t looked into the new input system so as of right now I cannot help much.
@leralix98
@leralix98 2 года назад
you can allow both unity imput system to work at the same time in the setting, maybe it will help
@Pkai1000
@Pkai1000 2 года назад
same
@Pkai1000
@Pkai1000 2 года назад
just disable the new one. go to: edit>> project settings>> player>> active input handling>> input manager(old) took me a bit to figure out
Далее
How to make an X-Ray Vision System (Unity Tutorial)
12:15
Редакция. News: 120-я неделя
52:26
Просмотров 853 тыс.
FIRST PERSON INTERACTION in Unity!
9:40
Просмотров 7 тыс.
Inventory System | Unity Tutorial
7:20
Просмотров 14 тыс.
How to jump in Unity (with or without physics)
16:09
Просмотров 39 тыс.
How To Interact With Objects [Unity Tutorial]
20:23
Просмотров 28 тыс.
20 Unity Tips in 10 MINUTES!
10:57
Просмотров 58 тыс.