Raycasting with the Unity’s New Input System

  Рет қаралды 9,730

One Wheel Studio

One Wheel Studio

Күн бұрын

Пікірлер: 31
@Fuzzel
@Fuzzel 2 жыл бұрын
You missed a thing when converting your old second and third example to the new input system: You continue to use Input.mousePosition which is part of the old input system and only works because in your project you still have both the new and old input system enabled. The new way is Mouse.current.position.ReadValue() or using the control mapping asset and creating a Vector2 binding for /position which you can then also read out inside an update using ReadValue(). Also instead of using isPressed you can also use wasPressedThisFrame and wasReleasedThisFrame for the start and end of the pickup
@OneWheelStudio
@OneWheelStudio 2 жыл бұрын
You are totally right! Big brain fart! Thanks. Also, I looked for something like isPressedThisFrame and missed it. Much appreciated.
@ap0stle
@ap0stle 2 жыл бұрын
I am currently trying to raycast using the new input system using input action to receive mouse position, but it returns the mouse position on global screen, when old input system mouse position returns the mouse position in the game window. I've been suffering a lot before I realized that my raycasts don't work because the mouse position from the new input system just is incorrect As you mentioned it, maybe you know how I can fix it?
@jakovincenttumane225
@jakovincenttumane225 2 жыл бұрын
4 min into the video and now my input system works perfect thanks bro
@umapessoa6051
@umapessoa6051 2 жыл бұрын
Awesome as always, keep up with the great work.
@thesilentwisp
@thesilentwisp 2 жыл бұрын
Really well explained thank you. Not sure if you can address this but I had a hard time giving the player a way to change mouse sensitivity with the new input system using the cinemachine camera.
@OneWheelStudio
@OneWheelStudio 2 жыл бұрын
Thanks! Glad it was useful. As for the mouse you could multiply the input by a float. Make it less than one to slow the mouse. More than one to speed it up. I haven’t done it but that would be my first attempt.
@thesilentwisp
@thesilentwisp 2 жыл бұрын
@@OneWheelStudio I've looked and could not for the life of me figure it out. If you happen to be unsure of what to make for your next video, that might be an idea since literally no one on KZbin covers reading mouse vector 2 input with the new input system in a cinemachine freelook camera.
@OneWheelStudio
@OneWheelStudio 2 жыл бұрын
The free-look camera? That is a bit tougher but not much. You can open up the "Cinemachine Input Provider" script and add the value that I was describing above. I'm going to be away all day today, but you're welcome to jump on the OWS discord and I bet we can get something working. You may be right that this could be a good quick follow-up video.
@yuunaito2120
@yuunaito2120 Ай бұрын
Thanks for your video. Love your explanation. But i wanna ask, what about selecting multiple object ? I've tried using for loop, but it didn't works. Silly me, im a beginner at programming field
@OneWheelStudio
@OneWheelStudio Ай бұрын
Multiple objects at once? Like dragging a selection box? Look up “rts selection” there’s some decent stuff out there 🙂 If you mean using raycast and selecting one after another then you could add the objects to a list as you select them? Maybe use a hot key like shift to could single or multiple selection.
@yuunaito2120
@yuunaito2120 Ай бұрын
@@OneWheelStudio umm, i guess what i am looking for is like a game where we need to find all hidden objects in one room And when we select all of them, the scene changed (to next stage). I know how to change the scene, but to make player select multiple objects one-by-one is my obstacle right now Oh list class ? Never thought of it.. I think i should try it
@RobLang
@RobLang 2 жыл бұрын
This is a great run through, thank you. One small thing - I found that your face cam had trouble focusing on your face when gesticulating. For me, a locked focus would be great!
@OneWheelStudio
@OneWheelStudio 2 жыл бұрын
Yep I’m with you. I’ve been struggling with the focus and learning a bunch in the process. Still a bit scared of locking the focus but I’ve changed some other settings which will hopefully let it stick to my face better. We’ll see. Glad the video is helpful!
@hansa5867
@hansa5867 2 жыл бұрын
The videos recommended in the beginning lack video links, I think, I didn't have them at least. So if you want to implement those, do so :)
@OneWheelStudio
@OneWheelStudio 2 жыл бұрын
There are links to the videos mentioned at 0:24 in the description as well as cards in the top right of the video. Happy to add others if I missed on.
@orchard800
@orchard800 2 жыл бұрын
Brilliant video. Just one question though; why enable sa.player in onenable()? And why enable it after subscribing to it, not before? If it wasn't enabled, would you be able to subscribe to it?
@OneWheelStudio
@OneWheelStudio 2 жыл бұрын
The order of enabling and subscribing doesn't matter - I don't know the exact inner workings of the Input Action Asset, but calling Enable doesn't turn the object on or off, it just tells it to listen to inputs and send out corresponding events. As for why we subscribe in OnEnable (and unsubscribe in OnDisable), this ensures that the functions are subscribed even if the object is turned on/off.
@JacksonThom
@JacksonThom Жыл бұрын
This is a great tutorial, but what is it about Cinemachine that can be set, to get it to follow the mouse pointer? I have been struggling with this for, soooo long! Thanks!
@OneWheelStudio
@OneWheelStudio Жыл бұрын
I'm not sure I would use Cinemachine for that. What you could do is raycast from the camera through the mouse and get a point on the ground. You could then have the camera "LookAt" the point on the ground. Do a quick google search for "unity raycast camera to mouse" and you should find plenty of results. Then look up "unity transform lookat"
@lee1davis1
@lee1davis1 2 жыл бұрын
Well you be doing a video on custom key binding manager with the new input system?
@OneWheelStudio
@OneWheelStudio 2 жыл бұрын
Done! ;) See if this video gets you moving in the right direction: kzbin.info/www/bejne/inWTg2iuZd5_Zrs
@leyone6828
@leyone6828 2 жыл бұрын
Hi, I am wondering if you have a tutorial of the project you demonstrated at 0:09, how objects are generated following the cursor but restricted in a certain grid (not sure if I say it correctly)
@OneWheelStudio
@OneWheelStudio 2 жыл бұрын
I don't have a video on that in particular, but the basic idea is to get the location (via raycast) which returns a Vector3. You can then round each of the components to an integer. Once they are rounded you can create a new vector3 with the rounded values and use THAT for the positioning.
@leyone6828
@leyone6828 2 жыл бұрын
@@OneWheelStudio Thank you so much for the detailed explanation!
@monkeymonkey69696
@monkeymonkey69696 6 ай бұрын
Thanks
@Seiku
@Seiku 2 жыл бұрын
Just a curious question, I'm still trying to grasp scripting and whatnot. I was learning and trying to implement a custom 2D collision script with raycasts and/or boxcasts on a sprite to detect ground collisions etc. Is this something that could be used for that, for a custom player collision, instead of updating every frame with the raycast?
@OneWheelStudio
@OneWheelStudio 2 жыл бұрын
Yep. Raycasting is a great way to detect ground collisions. Sebastian Lague has a great (but not simple) series on creating a 2D platformer using ray casting. Playlist: kzbin.info/aero/PLFt_AvWsXl0f0hqURlhyIoAabKPgRsqjz
@harryrithman1977
@harryrithman1977 2 жыл бұрын
Apparently unity does not come with input system I had get off asset store which one do you have
@OneWheelStudio
@OneWheelStudio 2 жыл бұрын
Yes, Unity still defaults to the "old" input system and the "new" system has to be imported with the package manager. This video used version 1.0.2 with Unity 2019.4.
@harryrithman1977
@harryrithman1977 2 жыл бұрын
@@OneWheelStudio no I mean when I downloaded unity there was no input system in package manager I had get one from asset store
Strategy Game Camera with Unity's New Input System
41:46
One Wheel Studio
Рет қаралды 31 М.
How to use TOUCH with the NEW Input System in Unity
24:11
samyam
Рет қаралды 72 М.
Человек паук уже не тот
00:32
Miracle
Рет қаралды 2,9 МЛН
Yay, My Dad Is a Vending Machine! 🛍️😆 #funny #prank #comedy
00:17
Миллионер | 2 - серия
16:04
Million Show
Рет қаралды 1,8 МЛН
Hot Reloadを紹介
6:41
【ゲーム個人開発】げんとめ
Рет қаралды 3
Unity's "NEW" Input System with C# Events
16:46
One Wheel Studio
Рет қаралды 90 М.
Unity's New Input System:  The Definitive Guide
32:07
DmanGames
Рет қаралды 31 М.
3rd Person Controller - Unity's New Input System
40:30
One Wheel Studio
Рет қаралды 85 М.
3 Interesting Ways Scriptable Objects can fix YOUR Unity3d project now!
24:29
Jason Weimann (GameDev)
Рет қаралды 86 М.
A Cinemachine Overview - If you're not using it. You should be.
12:59
One Wheel Studio
Рет қаралды 12 М.
How to use Unity's Input System
31:47
samyam
Рет қаралды 149 М.
How to use Unity's new input system [Unity/C# 🇬🇧 tutorial]
19:24
Unity's New INPUT SYSTEM | Unity Beginner Tutorial 2024
1:02:44
SpeedTutor
Рет қаралды 28 М.
Человек паук уже не тот
00:32
Miracle
Рет қаралды 2,9 МЛН