Selecting Objects with Raycast - Unity Tutorial

  Рет қаралды 231,147

Infallible Code

Infallible Code

Күн бұрын

Пікірлер: 240
@InfallibleCode
@InfallibleCode 5 жыл бұрын
NEXT VIDEO: Design Patterns in Game Development 👉 kzbin.info/www/bejne/p4SVhIOiaKx4ac0
@lachlanroberto5160
@lachlanroberto5160 3 жыл бұрын
I guess I am kind of randomly asking but do anyone know a good site to stream newly released series online?
@fisherzavier228
@fisherzavier228 3 жыл бұрын
@Lachlan Roberto i use flixzone. Just search on google for it =)
@breckenkoa4427
@breckenkoa4427 3 жыл бұрын
@Fisher Zavier Yup, been using Flixzone for years myself :)
@lachlanroberto5160
@lachlanroberto5160 3 жыл бұрын
@Fisher Zavier Thanks, signed up and it seems to work :) Appreciate it !!
@fisherzavier228
@fisherzavier228 3 жыл бұрын
@Lachlan Roberto glad I could help =)
@hatrer2244
@hatrer2244 Жыл бұрын
I like that you show the bugginess before using the tag and not resetting the color on hit. Good work.
@mtgstudios1556
@mtgstudios1556 2 жыл бұрын
After much struggling I got this to work. From someone who has neither used C# or Unity extensively this has helped me out massively.
@zentergames1622
@zentergames1622 5 жыл бұрын
I like the environment you used
@FuzzyDPozzy
@FuzzyDPozzy 4 жыл бұрын
a guy recommend me to learn raycast from this video , and guess what you just earned a subscriber!! I loved your tutorial man , you didn't let my attention go away. Thanks!
@N1ghtR1der666
@N1ghtR1der666 4 жыл бұрын
I enjoy the slower pace your videos go at so I dont need to pause every few seconds to keep up
@magicmamba
@magicmamba 4 жыл бұрын
4:46 i've had many a night like those after drinking...keep on coding! love the videos!
@Dbl_Plus_Good
@Dbl_Plus_Good Жыл бұрын
Charles! Your videos are great my dude! The game dev community misses you. Hope you and your family are well. Be great!
@SnailSpaceWTF
@SnailSpaceWTF 3 жыл бұрын
Hey, I'm pretty ignorantly at times. What's with the bold Unity Icon next to the UI and Environment in the Hierarchy? My mind is flagging that as interesting for some reason.
@Lycoon
@Lycoon 4 жыл бұрын
What if the selected object is a model? How to deal with the several materials?
@kyeperera7558
@kyeperera7558 3 жыл бұрын
@GameProgrammerGalaxy Most 3D software will allow you to make multiple materials onto one through UV texture baking.
@ZoidbergForPresident
@ZoidbergForPresident 5 жыл бұрын
5:40 THing is, an object can only have one tag, right? Depending on the complexity of the code and systems, what about writing an empty Selectable class and replacing the tag == selectable tag with GetComponent() != null ? Would that be acceptable? Also, wouldn't it be better to save the currently selected object's default material in order to restore it once unselected?
@lizkimber
@lizkimber 5 жыл бұрын
sure, but you can also do things by checking for components like GetComponent()
@Toocanzs
@Toocanzs 5 жыл бұрын
Yea I think this is a much more maintainable way to do this
@InfallibleCode
@InfallibleCode 5 жыл бұрын
Absolutely! I’m going to address this when we refactor the code in the next video. I’m going encapsulate portions of the SelectionManager so that the methods for selecting objects, casting rays, and reacting to selection are interchangeable.
@ZoidbergForPresident
@ZoidbergForPresident 5 жыл бұрын
@@lizkimber Isn't it what I proposed? :P
@GrashUriza
@GrashUriza 5 жыл бұрын
I actually don't like the tag system and use components exactly as proposed. Most of the time, you want to do something with the component so the code looks like: MyComponent mc = gameObject.GetComponent(); if (mc) { MyComponent.Stop(); // hammer time! } Cool things in play: 1) Remember, scripts are componets, just like Camera, Transform, RigidBody, Renderer. This applies to the scripts you write as well. 2) If you dig through the MonoBehavior Inheritance, you will find Unity has set up so we can use a component reference as a boolean to check if its null. Saves us from writing " != null ". 3) When you are making a new script file, you are creating a new C# class. So the example above, I created a script called MyComponent. I can then make a variable to store it. When GetComponent is called on the object, I get a valid reference if it has it, otherwise I get a null reference. As you get better with c#, there are some other really useful and cool things you can do because your scripts are classes. 4) when you have compounded objects ( game objects that consist of multiple game objects ), I typically keep the script at the root. Something like colliders, end up as children. When I use this setup, I use GetComponetInParent instead.
@iwonwahyudi
@iwonwahyudi 2 жыл бұрын
Can i apply this method to 3rd person controller view ?
@alexanderyankov666
@alexanderyankov666 3 жыл бұрын
Hi there, running my progress at the fourth minute of the video(4:14) I get presented with this error: Object reference not set to an instance of an object. Can you assist?
@mistervoldemort7540
@mistervoldemort7540 3 жыл бұрын
Did you fill the "highlight material" field in the inspector?
@mrsword6493
@mrsword6493 2 жыл бұрын
Had the same problem. My camera did not have the "MainCamera" tag.
@megusta4918
@megusta4918 4 жыл бұрын
Nice tutorial, Only one thing u should change is row Camera.main... to public Camera cam; //make public variable, then assign a camera object to it private void Update() { cam.ScreenPoint... } The reason is, that if you will call Camera.main, its like Camera.FindGameObjectWithTag("Main Camera"); and this is bad.. Have a nice day!
@stegy13
@stegy13 4 жыл бұрын
Aye this helped me out thanks dude!
@megusta4918
@megusta4918 4 жыл бұрын
@@stegy13 Glad to help :)
@benniegant
@benniegant 4 жыл бұрын
LOL, I love this tutorial I just signed up! I sorry I gotta share my experience with you real quick LOL. 1.) My character "BOX" feel straight throught the floor after hundreds of attempts (2nd.) Rotating my Charcter cause rotation caos hundreds of time. lastly. my character bounce around and tumbled for ever :P so... 2AM CST It boiled down to the check boxes of the rigid body for its contraints and two rigid body on the character's animation controller and the rigidboy I added to my cute cube. Although this was painfully long in time. I really wanted to learn this so in the end I walked away with experience! LOL IM LVL UP! THANKS A MILLION #IC ;]
@jeanbibek7566
@jeanbibek7566 5 жыл бұрын
This is what I call tutorial !!! It's so good ! Thank you Sir !
@petelewis1172
@petelewis1172 2 жыл бұрын
Best line in history "Looks like I'm swimming in a pool of p!ss"
@DevhieDevlikesminecraft
@DevhieDevlikesminecraft 10 ай бұрын
it only works on the unity gameobjects but it dosen't work on the custom model for me , anyway to fix that? im not that good at making games btw
@JonTopping
@JonTopping 3 жыл бұрын
just a point for people that are learning, declaring everything "var" isn't really too helpful. it would be better more helpful (and better practice) to declare the variables as what they are. I'm pretty much a total noob, and I'm trying to learn what you're doing so I can understand, not just copy, so at 3:50 there's three variables that I don't know what they are, and I have to go digging deeper somewhere else to try and figure it out
@holdengreene9717
@holdengreene9717 4 жыл бұрын
'Looks like im swimming in a sea of piss" that's when you went from informative to entertaining. Keep it up this helped me a lot.
@Driesipops
@Driesipops 4 жыл бұрын
thanks for the help... i was having trouble with brackeys older toturial and you helped me :D
@aarondavidlewis
@aarondavidlewis 4 жыл бұрын
And if the selection was a button, how would I trigger an event on the button? Specifically - a UI button like the play/pause button on a worldspace video screen? I'm using Vimeo's Unity Package, but I can't figure out how to get the VimeoPlayer to play/ pause when selected by the Ray.
@mubsdeveloper4523
@mubsdeveloper4523 3 жыл бұрын
Best Tutorial Ever
@mikosz08
@mikosz08 4 жыл бұрын
you look like Roman Bellic from GTA 4 also great tutorial
@TechLevelGames
@TechLevelGames 2 жыл бұрын
Very effective way to selected object! Thanks!
@hukudam
@hukudam 3 жыл бұрын
Please help me! I have a problem with IPointerDown. I instantiate a prefabs like button, pressing the button for a few seconds it destroys. I disabled some raycast and it was ok, when doing some repair it started to fail. Some buttons created are not recognizing IPointerDown. I don't understand why.
@LemauDev
@LemauDev 3 жыл бұрын
how can i detect object while it is visible on screen and also with blocking system .... is there any refrence for that ? thanks
@nickmckenzie4827
@nickmckenzie4827 3 жыл бұрын
If I understand this video correctly aren't you running GetComponent in every single frame ? i.e. if a mouse hovers over a selectable object you're hitting GetComponent every frame because it is in Update. I thought that was bad practice to do as GetComponent is quite expensive?
@mistervoldemort7540
@mistervoldemort7540 3 жыл бұрын
Unfortunately yes. I was also concerned by the material assignment: in my understanding, when the object is hovered over, every single frame, the material is set to default, then to highlight. But we only see the highlight because the frame is rendered at the end of the update loop. So I think this must be pretty slow...
@zainsagar
@zainsagar 5 жыл бұрын
Awesome tutorial bro... ✌️😇
@sergeylebedev1052
@sergeylebedev1052 3 жыл бұрын
Thank you, it was very convenient tutorial!
@InfallibleCode
@InfallibleCode 3 жыл бұрын
Glad to hear that!
@bronzekoala9141
@bronzekoala9141 4 жыл бұрын
Superb Tutorial! Just out of curiosity - why do you use the private keyword so often? Isn't private the default access modifier anyway? Is it for clarity?
@InfallibleCode
@InfallibleCode 4 жыл бұрын
That's exactly why. I prefer to be verbose by default just because I never know who may need to work with my code in the future.
@pulaksarkar7845
@pulaksarkar7845 Жыл бұрын
Hello Sir, I can’t able to add information by clicking different parts of a 3D object. Please help me , and if possible make a separate tutorial on that.
@screeck
@screeck 4 жыл бұрын
Hi. i need to get name of any object i aim on with crosshair. I used this: string name = gameObject.name; in the begining of if(selection.CompareTag(selectableTag)) but after printing object name in console i see only "Selection Menager". Can someone help me?
@davdev793
@davdev793 4 жыл бұрын
Hi. Nice and clean video .Any reason for not using functions like "onclick" and "onMouseOver" from monobehaviour? I saw a couple of people doing it your way but cant find the reason.
@ironoscar3948
@ironoscar3948 4 жыл бұрын
rider looks amazing! and content too
@aboziad100
@aboziad100 3 жыл бұрын
hi thank you for your tutorial, and i have a question please what if i'm using this tutorial in Augmented reality what difference it will make in the design? thank you
@rifat9264
@rifat9264 2 жыл бұрын
great man! works like magic thanks
@TigaLionessArt
@TigaLionessArt 5 жыл бұрын
Hey! I have a question - what if I want multiple various default materials, can I add multiple tags and for each one there's going to be another default? If it's possible, how to code it properly so that it doesn't report some errors?
@Ketselle
@Ketselle 4 жыл бұрын
Is there any way to use the ray from an XR Ray Interactor as the ray in code line 10 instead of a ray from the main camera? I'd like to put this effect on objects that are pointed to by a hand controller in VR (specifically using the XR Interaction Toolkit).
@nazarivanechko3967
@nazarivanechko3967 3 жыл бұрын
How do you add that red dot, is there a tutorial before this one?
@lordevilfishs3dprintingand184
@lordevilfishs3dprintingand184 3 жыл бұрын
Create a raw image and drop in your cursor/dot then make it the child of the main camera, note. it will be part of the canvas. You can create the raw image by left clicking on the Hierachy and going to UI
@mr.secret554
@mr.secret554 3 жыл бұрын
Thanks for the Tutorial. I have several objects in my project with different materials. How do I deal with them, so that each Object gets its default material back?
@ytmiva2
@ytmiva2 2 жыл бұрын
Store the default material in the object instead of in the manager. Then retrieve it from the object you're deselecting.
@rohitdoestech
@rohitdoestech 4 жыл бұрын
nice to see you using rider
@staceyantoinette2253
@staceyantoinette2253 4 жыл бұрын
Code Adjusted for UI element :) using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class SelectionManager : MonoBehaviour { public string selectableTag = "Selectable"; public Camera Camera_Environment; // Ray Origin (Labeled Camera_Environment due to Layering Cameras) public GameObject UI_Interactable; private Transform _selection; // keeps track of current selection void Update() { if(_selection != null) { UI_Interactable.SetActive(false); _selection = null; } var ray = Camera_Environment.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit)) { var selection = hit.transform; if (selection.CompareTag(selectableTag)) { UI_Interactable.SetActive(true); _selection = selection; } } } }
@veno8571
@veno8571 2 жыл бұрын
You are the best.
@sparrowhawk81
@sparrowhawk81 5 жыл бұрын
I wonder if you could get around some of those awkward null check statement using some null propagation from C# 6.
@InfallibleCode
@InfallibleCode 5 жыл бұрын
Oh yeah, I'm a sucker for syntactic sugar. I'll be cleaning up the code in a follow up video.
@sparrowhawk81
@sparrowhawk81 5 жыл бұрын
@@InfallibleCode sweet
@DavidB-rx3km
@DavidB-rx3km 4 жыл бұрын
@@sparrowhawk81 Does Unity C# support this?
@sadamps
@sadamps 3 жыл бұрын
Well done. Pluralsight had similar bloated tutorial on this and is wasn't half as clear as yours. Subscribed.
@verdo8462
@verdo8462 3 жыл бұрын
Hi, please tell me what is the script editor you are using
@vascobriz6747
@vascobriz6747 4 жыл бұрын
Thanks very much for this tutorial!
@vinodkumarakula6807
@vinodkumarakula6807 5 жыл бұрын
Great tutorial. Which code editor and theme are you using?
@InfallibleCode
@InfallibleCode 5 жыл бұрын
I'm using Rider. I have an affiliate link in the description if you want to check it out and learn more about it.
@lucasbergin4392
@lucasbergin4392 Жыл бұрын
Not sure if this is a dumb question but what IDE do you prefer for unity?
@carolinacandelise6689
@carolinacandelise6689 4 жыл бұрын
Hi! thanks for this tutorial! but how you set up the red dot?
@calebgunner
@calebgunner 3 жыл бұрын
Hi! For the red dot, you use UI. Simply make a canvas and select image (make sure sure the image is in the middle of the screen) Decrease the size of the image until it looks like a dot (you could use a circle for the image) Then simply change the image's colour to red.
@miltonsoto9733
@miltonsoto9733 5 жыл бұрын
men i have some problems, i make some GameObjects and save them as prefab item, but i can select them, its like the raycaster dont recognise them or can find them, i put a print to see some in console, but nothing appear so, have any idea about that?
@de0o0
@de0o0 3 жыл бұрын
Is this method optimal? This condition is happening every frame in update, there arent any better way to do that?
@janimations4652
@janimations4652 2 жыл бұрын
hi, is it possible that instead of material to put in a partical when highlighted?
@allaze-eroler
@allaze-eroler 3 жыл бұрын
what happen if i use a texture renderer behind the second camera? that is kinda problematic i'm been having lately...
@mustafageo
@mustafageo 5 жыл бұрын
Better to just save the default material from the object itself before changing it. This would allow you have different material for each object.
@joshuareeves9985
@joshuareeves9985 5 жыл бұрын
Yes! How is this done?
@joshuareeves9985
@joshuareeves9985 4 жыл бұрын
@mikael englund Ah, thank you.
@virtualreality3073
@virtualreality3073 2 жыл бұрын
comment on peut faire la meme chose mais avec XR RAy interactor
@BlueV205
@BlueV205 4 жыл бұрын
If I use multiple materials(For example, a cube was colored green and a sphere was colored red), how do I return them to their original materials?
@holamovie9343
@holamovie9343 4 жыл бұрын
this was super easy and helpful. thanks!
@garnishstudio3567
@garnishstudio3567 2 жыл бұрын
Thanks for the informative content! Any thoughts on how to modify the code to add different materials? This should be an obvious point, no?
@adequit
@adequit Жыл бұрын
Look up a video focused on interacting with different GameObject Components, should work!
@__Rizzler__
@__Rizzler__ Жыл бұрын
how bout adding an outline shader instead of changing colour?
@DiegoOliveiraProf
@DiegoOliveiraProf 4 жыл бұрын
nice, I did all my shooting mechanics using raycasts, now I am considering changing it to 'bullet.GetComponent().AddForce(mainCamera.transform.forward * 5000);' because I would like to see the bullet going forward :)
@josephboyer4828
@josephboyer4828 5 жыл бұрын
I'm really confused about something. When we hover over a Selectable object, _selection grabs that information. So before we even deselect the object, isn't it true that _selection != null ? Therefore, shouldn't it be resetting to defaultMaterial and back to highlightMaterial over and over while we're hovering our mouse over the object? I must be missing something here. :(
@josephboyer4828
@josephboyer4828 5 жыл бұрын
Oh wow it actually is doing this, I checked with a couple debug statements. So I guess this is just a rough start to this idea. Ok ok ok I'll go check out the other videos. :D
@karthiknallan559
@karthiknallan559 2 жыл бұрын
@@josephboyer4828 I know this was 3 years ago, but im struggling with this now lol, do you remember the solution for this problem?
@SpirusOfH
@SpirusOfH 4 жыл бұрын
How do you make it so that you can only select objects that are within a certain distance from the player? Like, I only want to be able to select an object if I'm standing close to it and looking at it, not if I look at it from across the room.
@katzekarlo2367
@katzekarlo2367 2 ай бұрын
very nice! thank you so much
@coverfaker8341
@coverfaker8341 5 жыл бұрын
excellent video editing skills.
@rakibjahan
@rakibjahan 5 жыл бұрын
Great video as always Charles! Setting the layermask when Raycasting results an increased performance, right?
@InfallibleCode
@InfallibleCode 5 жыл бұрын
Rakib Jahan yes, you’re correct. There are a number of ways to optimize the code for both flexibility and performance that I’ll be covering in the next tutorial.
@Postingyourvideos
@Postingyourvideos 4 жыл бұрын
@@InfallibleCode Where is the next one ?
@SpicyCurrey
@SpicyCurrey 2 жыл бұрын
@@InfallibleCode was this next video released? I can't find it
@kathyvdh5509
@kathyvdh5509 4 жыл бұрын
Is there a tutorial on how to set up this scene? Like what properties te objects have and stuff? (I'm a total beginner)
@zakilenck9759
@zakilenck9759 4 жыл бұрын
thank you so much for the tutorial
@TackleProd
@TackleProd 3 жыл бұрын
I'm having trouble implementing this in my 2D platformer. I want to select a room on the world map. I'm using your code exactly, set up all the tags, but nothing works..... HELP?!?
@TackleProd
@TackleProd 3 жыл бұрын
I fixed it :) Turns out I cant use your code exactly since I'm making a 2D game :P
@MrFarkasOfficial
@MrFarkasOfficial 4 жыл бұрын
fine. FINE. I`LL SUBSCRIBE!
@googleuser4720
@googleuser4720 3 жыл бұрын
Camera.main tho...
@konanws2228
@konanws2228 5 жыл бұрын
How do I add a red dot? I made a script with a Raycast, everything works fine but the only element missing is the red dot and I have no idea how to incorporate it in my game. Thx bud
@mrtobi4399
@mrtobi4399 5 жыл бұрын
me too ?
@michalrepovsky2208
@michalrepovsky2208 5 жыл бұрын
@@mrtobi4399 #metoo
@Rishraff
@Rishraff 3 жыл бұрын
I have a question, how do you link the dot in the screen to the ray cast?
@JonTopping
@JonTopping 3 жыл бұрын
I don't believe that's the way it works. What's happening is the dot in the middle of the screen is just a UI object that is in the middle of the screen, and the ray is being shot out the middle of the camera, which is what you see as the middle of the screen. This means the ray will always be where the red dot is.
@mzadro7
@mzadro7 4 жыл бұрын
Great video! Btw, what program are you using to write the scripts?
@InfallibleCode
@InfallibleCode 4 жыл бұрын
It’s called Rider
@jankystreams3337
@jankystreams3337 Жыл бұрын
Hey, awesome video btw. I do have one question, however. When I look at objects that aren't selectable, they turn to the default material that I set. Anyway that anyone could help me out?? Thanks! Edit: I am a TOTAL noob at Unity, I started a couple days ago, so I am sorry if I seem a little stupid.
@montymonster
@montymonster 4 жыл бұрын
What should I do if I only want to be able to select an item if I'm close enough?
@NoTAdrian115
@NoTAdrian115 4 жыл бұрын
Is not better getting the default material from the raycast at the start? Because if you try to hightlight items each item will had his own material.
@JasonStorey
@JasonStorey 4 жыл бұрын
well the ideal method is to use property blocks to change just the color of a single material instance, but that wasn't really the point of the tutorial.
@NoTAdrian115
@NoTAdrian115 4 жыл бұрын
@@JasonStorey Well, I guess what the point was the Raycast but i wanted to ask.
@ernestosapienza3791
@ernestosapienza3791 3 жыл бұрын
if I need to use this by clicking a button, would I need to change anything to this code? (the mouse is movable and not fixed with camera)
@borkyboy4286
@borkyboy4286 3 жыл бұрын
A bit late but you could just setup a OnMouseDown and then put your if(selectionRenderer != null) inside
@ofthedrk781
@ofthedrk781 4 жыл бұрын
hey dude could you make a tutorial about raycasting with colliders
@pchead54
@pchead54 4 жыл бұрын
Thank you ... Now i can make a gun with raycast :D
@PrincessSleepyTV
@PrincessSleepyTV 4 жыл бұрын
It's not working for me in Unity 2019 (Edit) It only works when I view one side of the object yet other sides don't register, the object is a simple unity cube with the correct collider. (Edit) For anyone else having this issue it has something to do with the lock cursor mode being on, not sure how to make it compatible with a centered cursor... any tips?
@dronehd-djimavicairfootage2295
@dronehd-djimavicairfootage2295 4 жыл бұрын
maybe you can search how to set the mouse position to the middle of the screen. with the FPS controller is should actually do that automaticly though. good luck!
@ringostarkiller7097
@ringostarkiller7097 5 жыл бұрын
useful video and great quality! thx u! :)
@aashutoshdabhade4325
@aashutoshdabhade4325 4 жыл бұрын
Wil it work if i use screenspace canvas panel?
@ytmiva2
@ytmiva2 2 жыл бұрын
Thank you for pointing out the code needs to be refactored. If someone were to build more functionality into the same code it would become an unmaintainable mess. But it's great to quickly see some results! I was wondering if there is an advantage to using Tags instead of empty interfaces?
@HellBound_101
@HellBound_101 3 жыл бұрын
But in addition to selecting the object with material, can you also enter the name of the object? Can this be done with a Text Canvas?
@aldigangster123
@aldigangster123 4 жыл бұрын
Hey Charles! I'm wondering what you think about OnMouseEnter / OnMouseExit. Would you use it in a scenario like this, or are there cons which speak against it and more for the Raycast in Update() method? For example, couldn't the primitives in the example inherit from a "public class Selectable", which implements the OnMouseEnter logic, which in turn changes the material like in your example scene. Would this be more "solid", as the objects themselves contain the information on how to behave during mouse cursor interaction via inheritance, instead of relying on tags being correctly set in the end? Not at all criticism in any way, I'm just wondering what I should go for in my project. I was heading more to OnMouseEnter/Exit before I've seen your video and I'm not quite sure now.
@ivensauro
@ivensauro 3 жыл бұрын
In the video, he used these example to be simple, but on an shotter by example the raycast can be better (or not, this depend of your project)
@openingchain328
@openingchain328 2 жыл бұрын
What if a person wants to select multiple objects
@adwitrahman2762
@adwitrahman2762 4 жыл бұрын
my object becomes pink after deselecting. Whats the fix for that
@Josh7GAS
@Josh7GAS 4 жыл бұрын
How do you set up your visual studio 2019 IDE?
@noghost6797
@noghost6797 3 жыл бұрын
You can look up in KZbin duh
@alexandergonzalez3376
@alexandergonzalez3376 3 жыл бұрын
how did you type that =/ sign?
@monkeyniples9985
@monkeyniples9985 3 жыл бұрын
you can use != in unity
@de0o0
@de0o0 3 жыл бұрын
Also I have one little question, what's the differnce between for example Ray declarations: "Ray ray" and "var ray".
@chonkgames
@chonkgames 3 жыл бұрын
Correct me if I’m wrong, but I think that if you are to use var, you have to immediately assign a value to it, and that way give it a type. And I believe it only works for local variables. My personal preference is to just go with Ray ray, but yeah, sometimes it is actually great for readability. Take a look at these two simple examples: 1. var dict = new Dictionary(); 2. Dictionary() dict = Dictionary();
@Rishraff
@Rishraff 3 жыл бұрын
Great video!
@RenderReady
@RenderReady 5 жыл бұрын
Love it!
@glalkia713
@glalkia713 3 жыл бұрын
Thanks man!
@tahsinxyz2037
@tahsinxyz2037 4 жыл бұрын
What about Objects with diffrent materails ? How can we do same thing with diffrent objects ?
@samsaraAI2025
@samsaraAI2025 3 жыл бұрын
Just a simple question? You say that you are taking the mouse poistion to do the raycast, but this is not true, you are using only the center of the screen to do the raycasting. Is this not the same as Camera.transform.forward?
@Ytomany
@Ytomany 4 жыл бұрын
The guy in the thumbnail looks like William Riker from Star Trek tng
@xbix-3176
@xbix-3176 4 жыл бұрын
This doesn't work with HDRP in Unity 2019.4.3. Any ideas why?
@Trashboat1060
@Trashboat1060 4 жыл бұрын
Renderer is render
@fragelius
@fragelius 5 жыл бұрын
how would one use this for 3rd person view so item would highlight on mouse hover over object
@fragelius
@fragelius 5 жыл бұрын
err never mind ... it was the typos in code :D
@MJ720
@MJ720 2 жыл бұрын
Great tutorial. Think I'm doing something wrong as the selected material becomes purple (i.e. no material??). Work in progress I guess.
@alexanderthegreat7462
@alexanderthegreat7462 4 жыл бұрын
I wrote the whole code, but my objects dont turn back to normal when i dont hover over them
@agent6467
@agent6467 4 жыл бұрын
hahaha rip
SOLID Principles in Unity
14:58
Infallible Code
Рет қаралды 154 М.
Raycasts in Unity (made easy)
16:30
Game Dev Beginner
Рет қаралды 103 М.
1% vs 100% #beatbox #tiktok
01:10
BeatboxJCOP
Рет қаралды 49 МЛН
人是不能做到吗?#火影忍者 #家人  #佐助
00:20
火影忍者一家
Рет қаралды 12 МЛН
Smart Sigma Kid #funny #sigma
00:33
CRAZY GREAPA
Рет қаралды 38 МЛН
6 Years of Blender in 13 Minutes
13:01
Kaizen
Рет қаралды 399 М.
CLEAN Game Architecture with ScriptableObjects | Unity Tutorial
13:12
Sasquatch B Studios
Рет қаралды 20 М.
How I Would Start Game Development (If I Started Over)
16:59
Thomas Brush
Рет қаралды 144 М.
Unleash the Power of Raycasts with Dot Product (Unity Tutorial)
12:53
Infallible Code
Рет қаралды 39 М.
20 Advanced Coding Tips For Big Unity Projects
22:23
Tesseract
Рет қаралды 204 М.
How To Build An Event System in Unity
8:01
Game Dev Guide
Рет қаралды 417 М.
I Made the Same Game in 8 Engines
12:34
Emeral
Рет қаралды 4,3 МЛН
How Thinking in Systems Can Improve Your Code
10:16
Infallible Code
Рет қаралды 32 М.