My Favorite way to Click on GameObjects

  Рет қаралды 50,480

VR with Andrew

VR with Andrew

Күн бұрын

Пікірлер: 50
@Miss-ex1gnt
@Miss-ex1gnt Жыл бұрын
Do keep mindful of any objects that may block the raycast! I had a canvas with components that I animated out of my screen, but they kept on blocking the raycast. I added "deactivate raycast target" at the end of the animation and solved the "mystery". Still, I must admit, I have gone bonkers until I finally realized what it was! DX
@justcore69
@justcore69 5 ай бұрын
Your comment just saved a lot of my gamejam time. Thank you!
@Roadtotarget
@Roadtotarget 2 ай бұрын
Don't forget to add Box Collider component to your objects you want to click
@sakeb1
@sakeb1 7 ай бұрын
3:47: go to definition, best thing I learned here woah
@emilyhorton996
@emilyhorton996 Ай бұрын
deserves way more views and thumbs ups. thank you so much!
@prhc
@prhc Жыл бұрын
thanks for the video, when using this technique with UI toolkit in unity version 2021.3.24 i had the problem of not being able to select any game objects, only PanelSettings were being selected. i solved this by setting the picking mode of the root visual element to Ignore in the UI Builder
@sissond
@sissond 2 жыл бұрын
I needed this like 11 months ago ;) Might go back and make that functionality more elegant
@VRwithAndrew
@VRwithAndrew 2 жыл бұрын
I'll know for next time! :)
@zuban1988
@zuban1988 Жыл бұрын
Thank you! BTW, I had a problem with code generted mesh, it did not fire the events until you add collider (MeshCollider in my case), then it works.
@rd88ify
@rd88ify 10 ай бұрын
Thanks! This resolved my issue. In my case I had to add a Box collider to my 3D game object
@LetsFacetheMusicandDance
@LetsFacetheMusicandDance 3 ай бұрын
I had the exact same problem ... wish I saw this comment sooner : )
@ImKyleConway
@ImKyleConway 5 ай бұрын
I've set up the script and it works great, however I am trying to use this to inspect items but when I adjusted the main camera's near clipping plane, it no longer worked. Anyone know why?
@danilocolassoo
@danilocolassoo Жыл бұрын
That's a really good Interactable objects approach! Specially combined with UnityEvent
@VRwithAndrew
@VRwithAndrew Жыл бұрын
Thank you, and exactly! It's incredibly versatile.
@ms.awesome
@ms.awesome Жыл бұрын
okay so im using Cursor.lockState = CursorLockMode.Locked; because my game is in first person but this prevents being able to click on the object like this! Any way to fix it or workaround it?
@VRwithAndrew
@VRwithAndrew Жыл бұрын
There's some code in the Event System that prevents events if the cursor is locked if I remember correctly. There isn't an easy workaround, but you may be able to copy the script into a new file and make the necessary edits.
@adfs774
@adfs774 Жыл бұрын
This is so much better than using annoying raycasting. Thx so much!!1
@froggothecommentator8036
@froggothecommentator8036 4 ай бұрын
sorry but im having some problem with the clicking system rn. It keeps telling me that im having the error "CS0246:the type of namespace name... could not be found". Could you help me with this please?
@mast1665
@mast1665 Жыл бұрын
Are there any more resources on this? I just started my unity journey and cant quite get my head around this system. The Events seem to fire endlessly, not only when (for example) clicking on the GameObject I added this script too... No matter where I move/click the mouse. The script answers always.
@VRwithAndrew
@VRwithAndrew Жыл бұрын
Not exactly! However, feel free to join the Discord, and we'll see if we can figure it out.
@mast1665
@mast1665 Жыл бұрын
@@VRwithAndrew I had to use a box collider! Today was a learn intensive day. Thank you :)
@ritori3556
@ritori3556 Жыл бұрын
Hi! Thank you for great tip! However, as a beginner, I suffered a lot in implementing it. Could you please share or show in your tutorial MaterialApplier script :( In trying to make it on my own, I got completely lost
@VRwithAndrew
@VRwithAndrew Жыл бұрын
It's just a simple example script and not necessary for the implementation. You can easily just put debug statements instead.
@smirelesz
@smirelesz Жыл бұрын
Great video. Elegant solution. Thank you!
@marcoballan4067
@marcoballan4067 4 ай бұрын
is there any way of implementig this with right clicks or does it only works with left clicks?
@VRwithAndrew
@VRwithAndrew 4 ай бұрын
Yeah, you can use the PointerEventData with some code like this. public override void OnPointerClick(PointerEventData eventData) { if (eventData.button == PointerEventData.InputButton.Right) { // Your code } }
@AgalyAbdyev
@AgalyAbdyev Жыл бұрын
sorry but i have error on MaterialApplier. How to solve ?
@VRwithAndrew
@VRwithAndrew Жыл бұрын
That's just an example script. You can have a print statement there instead.
@DexterCrappell
@DexterCrappell 11 ай бұрын
@@VRwithAndrew I just started with unity, how would I add the print statement?
@VRwithAndrew
@VRwithAndrew 11 ай бұрын
@@DexterCrappell Within the click functions, you can write... print("Click"); or print("Hover"); Depending upon what the pointer event is
@ДосталиЕвский
@ДосталиЕвский Жыл бұрын
Can you please clarify how to select an object using a gamepad controller? I'm currently in the process of setting up my input systems for the gamepad, but I'm unsure of how to accomplish this task. Thank you for your assistance!
@clamarped
@clamarped Ай бұрын
Great video, however, I would have loved it if you had explained how it would work with different objects with different actions, as I can't really see that function with how you show it in the example sadly.
@castlecodersltd
@castlecodersltd 4 ай бұрын
Very helpful, thank you 🙂
@VRwithAndrew
@VRwithAndrew 4 ай бұрын
Happy to help!
@ClimFreeFeelRain
@ClimFreeFeelRain Жыл бұрын
How can I
@Arsen592_Old
@Arsen592_Old Жыл бұрын
Strange but I don't have Input System UI Input Module in my EventSystem, and I can't add it
@VRwithAndrew
@VRwithAndrew Жыл бұрын
Do you have the Input System Package installed?
@Arsen592_Old
@Arsen592_Old Жыл бұрын
@@VRwithAndrew oh I didn't input it, thanks
@indikaWijesooriya
@indikaWijesooriya 2 жыл бұрын
This is a great tip Andrew!. Thanks. It's been a while :-) I'd also like to know your take on custom graphic raycasters. Eg: Projecting a UI to a curved object (probably with render texture) and getting the raycast input to convert to a UI input. Mainly in VR
@VRwithAndrew
@VRwithAndrew 2 жыл бұрын
I haven't really created my own raycaster before. But, I'm pretty sure you can! I also have some experience with the Curved UI Asset. Technically, you may be able to use the existing Ray Interactor from XRI, a Custom Event System, and a visual element to bend the UI.
@martinjacobsen5974
@martinjacobsen5974 3 ай бұрын
Yeah sorry. It's a super sweet video and very to the point. But as a beginner I have no idea what I'm looking at what is from unity and what you wrote ahead of time. I can see that it's a super straight forward system once it's set up but I needed the "setting it up from zero" Thanks for the video though.
@appleseedgames6934
@appleseedgames6934 Жыл бұрын
Thought this would really easy but magically it's not working, followed the tutorial the exact same and followed other issued people have had but it's just simply not returning a debug on click at all
@appleseedgames6934
@appleseedgames6934 Жыл бұрын
Solution: Cursor.lockState isn't compatible with it. Pretty making this entirely useful except for a handful of cases, don't waste your time with this
@tahirdevlog2047
@tahirdevlog2047 Жыл бұрын
thank you
@VRwithAndrew
@VRwithAndrew 11 ай бұрын
Happy to help
@Dan-ed1sk
@Dan-ed1sk Ай бұрын
This is not really helpful, you don't provide enough info
@ashwinsuresh1476
@ashwinsuresh1476 2 жыл бұрын
andrew tate , top g
The Power of Scriptable Objects as Middle-Men
17:41
samyam
Рет қаралды 131 М.
Raycasts in Unity (made easy)
16:30
Game Dev Beginner
Рет қаралды 103 М.
[BEFORE vs AFTER] Incredibox Sprunki - Freaky Song
00:15
Horror Skunx 2
Рет қаралды 21 МЛН
How Strong Is Tape?
00:24
Stokes Twins
Рет қаралды 53 МЛН
I Made the Same Game in 8 Engines
12:34
Emeral
Рет қаралды 4,3 МЛН
How to get Mouse Position in 3D and 2D! (Unity Tutorial)
10:20
Code Monkey
Рет қаралды 143 М.
How I Mastered GODOT In Only a WEEK!
7:08
Simplicity
Рет қаралды 10 М.
Clicking on a 3D object (Unity/C# tutorial)
9:44
Mina Pêcheux
Рет қаралды 19 М.
A new way to generate worlds (stitched WFC)
10:51
Watt Designs
Рет қаралды 547 М.
choosing a game engine is easy, actually
15:08
samyam
Рет қаралды 618 М.
1 Year of Learning Game Development In 6 Minutes
6:01
Giedzilla
Рет қаралды 2,6 МЛН
What does a Game Engine actually do?
16:45
Ellie Rasmussen
Рет қаралды 172 М.
How To Use Scriptable Objects in Unity
4:28
Game Dev Guide
Рет қаралды 109 М.
The Unity Tutorial For Complete Beginners
46:39
Game Maker's Toolkit
Рет қаралды 4 МЛН
[BEFORE vs AFTER] Incredibox Sprunki - Freaky Song
00:15
Horror Skunx 2
Рет қаралды 21 МЛН