No video

How to Jump in VR using Unity's New Input System

  Рет қаралды 22,677

Justin P Barnett

Justin P Barnett

Күн бұрын

Пікірлер: 165
@Nickk888SA
@Nickk888SA 3 жыл бұрын
If anyone uses SteamVR and have problems with the Height calculation(Rig getting under or above the level, etc.), just don't calculate the center with the collider's Y center value but use the _xrRig.cameraInRigSpaceHeight value devided by 2, it perfectly calculates the height, clamping to min 1 also helps a lot! Here's my code: void Update() { var center = _xrRig.cameraInRigSpacePos; _collider.height = Mathf.Clamp(_xrRig.cameraInRigSpaceHeight, 1.0f, 3.0f); _collider.center = new Vector3(center.x, _collider.height / 2, center.z); }
@JustinPBarnett
@JustinPBarnett 3 жыл бұрын
Thanks so much for finding this Nickk888!
@me_in_vr8478
@me_in_vr8478 3 жыл бұрын
Great tip Nick! Settled some of my falling through the floor problems. Not using SteamVR, but Oculus Quest/Link and it worked for me.
@Nickk888SA
@Nickk888SA 3 жыл бұрын
@@me_in_vr8478 good to know it also works on other devices! Thanks for the info!
@mohammadrazakhan3852
@mohammadrazakhan3852 3 жыл бұрын
@@me_in_vr8478 hey my player is also falling from the scene so what should I DO ? WHERE should I paste this code ??
@me_in_vr8478
@me_in_vr8478 3 жыл бұрын
@@mohammadrazakhan3852 So, I'm using a script I've created to handle movement and jumping and stuff like that. It's my PlayerController.cs and I have the code in the Update method, like so: // Update is called once per frame void Update() { var center = xRRig.cameraInRigSpacePos; capsuleCollider.height = Mathf.Clamp(xRRig.cameraInRigSpaceHeight, 1.0f, 3.0f); capsuleCollider.center = new Vector3(center.x, capsuleCollider.height / 2, center.z); }
@Joooooooooooosh
@Joooooooooooosh 2 жыл бұрын
I have 20+ years of programming experience and this is all so confusing to me. Thank you for taking the time to make this very detailed tutorial.
@JustinPBarnett
@JustinPBarnett 2 жыл бұрын
You’re welcome!
@Arashi256
@Arashi256 2 жыл бұрын
Your jumping tutorial works fine as long as you're on the ground (ie. Y: 0) but you cannot jump from an elevated position. I set everything in my scene that I could climb up like ramps, platforms and so on to a "Ground" layer and changed your code to use: - [SerializeField] private LayerMask whatIsGround; [SerializeField] private Transform groundCheckPoint; ... private bool isGrounded => Physics.OverlapSphere(groundCheckPoint.position, .25f, whatIsGround).Length > 0; groundCheckPoint is just an empty child GameObject set to (0,0,0) on the XROrigin. Set whatIsGround to your "ground" layer, and you can jump from any elevation as long as what you're standing on is on the "ground" layer. Hope this helps somebody.
@davidsimon9353
@davidsimon9353 2 жыл бұрын
Thanks for the suggestion!... also found if you don't want to create a new layer and assign to objects just set .Length>1. I think the capsule collides with the overlap sphere so setting it >1 accounts for that one collision and any others it finds must be ground or something else. Thanks again!
@MrDonovanCerminara
@MrDonovanCerminara Жыл бұрын
Thanks very much for sharing this. It helped me!
@DaRealViso
@DaRealViso Жыл бұрын
Thank you!
@LowPolyBeans.
@LowPolyBeans. 10 ай бұрын
this helped so much as i am making a spiderman, no, arachnid person, game.
@JustinPBarnett
@JustinPBarnett 3 жыл бұрын
Download the Project (for FREE): www.vrcreators.io/codedownloads
@termi5666
@termi5666 2 жыл бұрын
The ones using XROrigin instead of XRRig. You have to install another package called "XR Core Utilities". Go to Package Manager-> + -> Add package by name -> copy this: com.unity.xr.core-utils Then in your script add the namespace: using Unity.XR.CoreUtils; And the methodes change a little bit, ex: using Unity.XR.CoreUtils; ... { private XROrigin _xrOrigin; private CapsuleCollider _capsuleCollider; ... void Start() { _xrOrigin = GetComponent(); } void Update() { var center = _xrOrigin.CameraInOriginSpacePos; _capsuleCollider.center = new Vector3(center.x, _capsuleCollider.height / 2, center.z); _capsuleCollider.height = Mathf.Clamp(_xrOrigin.CameraInOriginSpaceHeight, 1.4f, 1.8f); } ....
@bobjrgeorge4577
@bobjrgeorge4577 Жыл бұрын
you save me thank
@jannahconsortium4521
@jannahconsortium4521 Жыл бұрын
could you please, explain how to do this. Nothing is working for me
@quindogfish480
@quindogfish480 11 ай бұрын
Thank you!!
@anthonyparker1589
@anthonyparker1589 3 жыл бұрын
Short, sweet, and to the point, will never unsub
@JustinPBarnett
@JustinPBarnett 3 жыл бұрын
many thanks! 🙏
@cleverballoon6535
@cleverballoon6535 3 жыл бұрын
Agreed, Valems videos are good but they are tricky for me to follow, this is perfect, functionality plus a good explanation so you learn how Unity works
@JustinPBarnett
@JustinPBarnett 3 жыл бұрын
@@cleverballoon6535 Appreciate you!!
@cleverballoon6535
@cleverballoon6535 3 жыл бұрын
@@JustinPBarnett Thanks its awesome to see youtubers who respond to their viewers, I have a small gaming channel and i try to do the same since it means a lot to everyone
@JustinPBarnett
@JustinPBarnett 3 жыл бұрын
@@cleverballoon6535 sure thing, yea I love interacting with people in the comments. Good luck with your channel!!
@elsyndur4415
@elsyndur4415 3 жыл бұрын
Thanks so much for making this! I was struggling for a couple of days to figure out how to get specific buttons to do things in VR. You wouldn't think it would be that hard, but it was, for me!
@JustinPBarnett
@JustinPBarnett 3 жыл бұрын
You're so welcome! Yea this VR stuff is a bit complicated at first.
@anthonyjackson9194
@anthonyjackson9194 2 жыл бұрын
I realy like the XR interaction toolkit, I think it works well and is pretty easy to understand, BUT it definitely doesnt work once you need to extend it to different buttons on the controllers. This video helps massively thank you
@zoestraw6444
@zoestraw6444 3 жыл бұрын
I consider myself a reasonably competent C# coder, but damn you've really got some moves. My girlfriend (a much better coder than me) was teaching me about lambdas a while ago but I hadn't gotten an opportunity to actually use one until this video. Neat stuff!
@JustinPBarnett
@JustinPBarnett 3 жыл бұрын
Omg they're WONDERFUL once you get the hang of them. Saves so much time!
@spotlessapple
@spotlessapple 2 жыл бұрын
Great tutorial! Using this setup for my current project, awesome content. I was having issues with the IsGrounded function in the video always registering false for the jump, but after making a small change to it everything began working as expected. This might be due to some specific setup unique to my project, but I'll leave the change down below in case others run into something similar: private bool IsGrounded => Physics.Raycast( transform.position, Vector3.down, GetComponent().bounds.extents.y + 0.1f );
@elbodomo8875
@elbodomo8875 2 жыл бұрын
For anyone using Terrain and having trouble, bc the does not recognize it. Try using this (transform.position +new Vector3(0,0.1f,0)) position for the ray cast and make the ray 0.2f long
@devchicken1482
@devchicken1482 3 жыл бұрын
Great tutorials! it would be awesome to see a realistic, Boneworks like climbing system. But dont stress yourself out and keep up the very helpful tutorials.
@JustinPBarnett
@JustinPBarnett 3 жыл бұрын
Great suggestion! I'd love to do that
@burrgurrman2433
@burrgurrman2433 2 жыл бұрын
You're a lifesaver my guy! I've been freaking out for days on how I can get this to work
@zoestraw6444
@zoestraw6444 3 жыл бұрын
Now that Air Link is out developing with Quest 2 as your in-editor test headset is actually super easy, it's great! You just have Air Link up and can run and quit the game as easily as you would with the Rift S, big fan. I don't think that it's quite as smooth as Virtual Desktop was for actually *playing* games wirelessly, but as a development unit I'm having a much easier time with it.
@JustinPBarnett
@JustinPBarnett 3 жыл бұрын
Absolutely! Air Link is a game changer. (especially when I need to use my long USB-C cable to charge my light while I'm filming instead of having it plugged into the Quest 2 😅)
@swannschilling474
@swannschilling474 2 жыл бұрын
Man your new space looks awesome, your thumnnais are catchy and your content rocks!! 😁
@JustinPBarnett
@JustinPBarnett 2 жыл бұрын
Thanks a ton!
@me_in_vr8478
@me_in_vr8478 3 жыл бұрын
Great video! Thanks for the tutorials. I actually just finished implementing jump this way, like almost exactly (different application of physics to the Rigidbody by specifying Force.Impulse and having a public float for gravity to mess with) only figured it out one day before you posted. This took lots of looking at outdated guides and reading new unity documentation. I was still working on figuring out the capsule collider thing and your guide saved me some extra time and headaches here. All the VR guides out there are about using the Character Controller or the old input system and didn't quite translate. There's still a bunch of stuff for me to work out with using Rigidbody and Player Controller. Collisions are a big one--Using XR Grab Interactables and running into walls that send me falling through the floor! Also was having fun with objects that transform.localScale of my player on collision, with a cooldown coroutine--but when I revert to normal size I'm falling through my ground plain. I'm hoping to avoid just using constraints because there will be things I want to knock me around later, and constraining the Y axis turns off the ability to jump. I think next steps for me is figuring out a way to handle steps/stairs/slopes without a Character Controller. Do you know if you've covered any of these or have any quick tips?
@JustinPBarnett
@JustinPBarnett 3 жыл бұрын
I don't think I've covered those topics, but 100% will be getting to most if not all of them in the near future!
@JustinPBarnett
@JustinPBarnett 3 жыл бұрын
Thanks so much for your feedback!!
@me_in_vr8478
@me_in_vr8478 3 жыл бұрын
@@JustinPBarnett So theres a weird issue with jumping that I'll call the trampoline effect. Each jump is higher than the last. It doesn't matter whether you move or teleport in between or how much time you spend on the ground, the height of each consecutive jump is greater. I went back in and cleaned up my code.. Then I just switched to your exact methods even to make sure wasn't just something I'd goofed on in my own trial and error. I thought perhaps the jumpForce variable was being changed, so I did Debug.Log("Jumped with " + jumpForce); but it hasn't changed. the grounded check is working, so I'm not double jumping. The height of each jump just increases.... can you test if you are experiencing the same?
@JustinPBarnett
@JustinPBarnett 3 жыл бұрын
@@me_in_vr8478 oh huh, I didn't test it enough to see if that would happen. I'll look into it. You can join the discord and chat if you want! discord.gg/6mzMQx5VKk
@Arashi256
@Arashi256 2 жыл бұрын
I was using a character controller component attached to my XROrigin, but I changed it to rigidbody/capsule collider in order to do this tutorial. But one issue is that when hitting an obstacle with the XROrigin with a character controller component, my XROrigin would just stop - but when hitting an obstacle with a rigidbody/capsule collider, my XROrigin "stutters" against the obstacle rather than just stopping. Is there a fix?
@nilayg6807
@nilayg6807 5 ай бұрын
I'm facing this issue to, lmk if you found a solution please This is a physics based jump movement, alot of Unity forum is divided in how it's done and most agree it's best for the user to not do so. Using the Character Controller has been great, I am actively looking for a solution that leverages it
@jeffleclerc2904
@jeffleclerc2904 2 жыл бұрын
Again, another great tutorial. I'm using Unity 2020.3.29 and XR Rig is deprecated and it's now called XR Origin. I first started following your tutorial knowing I should switch all these Rig for Origin but towards the end, I had _collider underlined and couldn't fix it. So I thought to just change the name of my Origin in Unity and switch my code to Rig to follow yours but Visual Studio told me I couldn't do that. Now i'm stuck not being able to adjust the height of the capsule collider. The first part worked, I could jump. I also decided not to use some lines to allow pressing the A button many times and just fly. That's exactly what I wanted. But the height part is pretty cool and I'd really like to get it working.
@JustinPBarnett
@JustinPBarnett 2 жыл бұрын
There are some scripts you'll have to rename in order to update from xrrig to xrorigin. And the name of the variable for camera height is different now
@mboe94
@mboe94 3 жыл бұрын
Dude, you are absolutely awesome. Thank you very much! I really do hope your Patreon takes off - I hope for many new game tutorials there :)
@JustinPBarnett
@JustinPBarnett 3 жыл бұрын
Thanks so much! And I hope so too 😅, regardless there's lots more tutorials to come!
@robertoedlin
@robertoedlin 3 жыл бұрын
Awesome. Thanks for doing this! Although I'm currently working on a non locomotion vr project at the moment but definitely want to know how to jump in vr. I could never get it quite right.
@JustinPBarnett
@JustinPBarnett 3 жыл бұрын
Sure thing! You'll do a locomotion project eventually I'm sure!
@DassVeryGood
@DassVeryGood 3 жыл бұрын
HAHAHA I picked up the tablet from your last tutorial and since both the tablet and the player capsule have rigid bodys, I was shot out of the scene at 100 mph! Still great video keep it up!
@JustinPBarnett
@JustinPBarnett 3 жыл бұрын
OMG 😂
@ProdigiaGames
@ProdigiaGames 3 жыл бұрын
I was just looking into this and suddenly this tutorial appears, giving me all the information I didn't know I needed...GET OUT OF MY HEAD 🤣
@JustinPBarnett
@JustinPBarnett 3 жыл бұрын
Hahaha, glad I could help!
@Jamie_Howes
@Jamie_Howes 3 жыл бұрын
Hey, any chance you make a tutorial on how to make accounts and a login screen when you start up the game. Also if possible could you make a tutorial on how to make a admin panel for only people you give it to (part of the account system kinda)
@JustinPBarnett
@JustinPBarnett 3 жыл бұрын
Yea I can look into that!
@tymcfie3154
@tymcfie3154 3 жыл бұрын
your next video should explain how to set up hand tracking. For example something that can be used with the quest
@JustinPBarnett
@JustinPBarnett 3 жыл бұрын
Definitely gonna try to do that pretty soon now that I’ve got the quest 2!
@AdamCheong
@AdamCheong 3 жыл бұрын
RE: Character controller following camera in roomscale. This way seems nicer than overriding the CharacterControllerDriver in one of your previous videos.
@JustinPBarnett
@JustinPBarnett 3 жыл бұрын
Totally agree! I'm getting better as I learn too!
@TheEnchantedPickaxeHDGaming
@TheEnchantedPickaxeHDGaming 7 ай бұрын
Great tutorial! My only problem right now is maintaining momentum and control mid-air is there something I can add to the existing script to fix this?
@SeanKennedy100
@SeanKennedy100 2 жыл бұрын
This doesnt work. I've run through it multiple times now. Sadly doesnt work anymore idk why.
@JustinPBarnett
@JustinPBarnett 2 жыл бұрын
Join the discord and we can help you troubleshoot!
@ElPatoEncabronado
@ElPatoEncabronado 3 жыл бұрын
thanks, I've been looking for a tutorial like this. :)
@JustinPBarnett
@JustinPBarnett 3 жыл бұрын
No problem!
@EricPeters
@EricPeters 3 жыл бұрын
Great tutorial. As always :) And if you are looking for a new tutorial idea: How about a 3rd person controller? Similar to MOSS or ASTRO BOT ...
@JustinPBarnett
@JustinPBarnett 3 жыл бұрын
Thanks! And cool idea! I'd love to give that a shot!
@Didrik84
@Didrik84 3 жыл бұрын
hi i have tried to make my vr player jump for 11 houers and i cant get it to work can anyone help me
@JustinPBarnett
@JustinPBarnett 3 жыл бұрын
Join the discord and we'll help you out!
@SigmaPhonkBabyGronk
@SigmaPhonkBabyGronk 3 жыл бұрын
Thank you so much!
@JustinPBarnett
@JustinPBarnett 3 жыл бұрын
You’re so welcome!
@smalrebelion
@smalrebelion 2 жыл бұрын
I've been trying to implement flight in XR toolkit for a couple days now (I'm a noob). This got me more than halfway there (I just didn't add any of the raycaster stuff so I can jump in the air). Can you make a video like this where you explain how to replace "Vector3.up" with a vector3 of your controllers orientation? Maybe also how to put the force in a while loop?
@smalrebelion
@smalrebelion 2 жыл бұрын
Scratch that. I found your swimming tutorial and implemented the reference to the camera direction as the force direction. Next step will be to make an option to increase all acceleration vector components orthogonal to the current direction of travel by a specific factor to make turning more responsive and maybe throttle the acceleration based on trigger pull extent. It's pretty rough but for anyone interested it's here: github.com/pdettinger/Unity-XR-Interaction-Toolkit/blob/main/PlayerFlight.cs using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.InputSystem; [RequireComponent(typeof(Rigidbody))] public class PlayerFlight2 : MonoBehaviour { [SerializeField] InputActionReference FlyActionReference; // Set to XRI righthand/fly [SerializeField] InputActionReference AirbreakActionReference; // Set to XRI righthand/Airbreak [SerializeField] Transform TrackingReference; // Drag Your hand gameobject into this field [SerializeField] float FlyForce = 50.0f; [SerializeField] float AirbreakFactor = 5.0f; Rigidbody _body; Vector3 TurnVector; void Awake() { _body = GetComponent(); _body.constraints = RigidbodyConstraints.FreezeRotation; } void FixedUpdate() { if (FlyActionReference.action.IsPressed()) { Vector3 worldRotation = TrackingReference.TransformDirection(Vector3.forward); _body.AddForce(worldRotation * FlyForce, ForceMode.Acceleration); } if (!FlyActionReference.action.IsPressed() && AirbreakActionReference.action.IsPressed()) { Vector3 crrntVelocity = _body.velocity; _body.AddForce(crrntVelocity * -1 * AirbreakFactor, ForceMode.Acceleration); } } }
@Nuckl3ar
@Nuckl3ar 3 жыл бұрын
Have you tried implementing jump mechanics only relying on the Character Controller instead of adding a rigid body on top of it? My main problem is keeping momentum while jumping
@JustinPBarnett
@JustinPBarnett 2 жыл бұрын
Personally, I like to keep as much stuff physics-based as I can in my games
@saradotterer2629
@saradotterer2629 Жыл бұрын
For quest 1, How do I adjust the following code for jumping in unity version 2021.3.10f1 with the following four errors? Code: using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.XR.Interaction.Toolkit; [RequireComponent(typeof(Rigidbody))] public class PlayerController : MonoBehaviour { [SerializeField] private InputActionReference jumpActionReference; [SerializeField] private float jumpForce = 500.0f; private XRRig _xrRig; private CapsuleCollider _collider; private Rigidbody _body; private bool IsGrounded => Physics.Raycast( new Vector2(transform.position.x, transform.position.y + 2.0f), Vector3.down, 2.0f); void Start() { _xrRig = GetComponent(); _collider = GetComponent(); _body = GetComponent(); jumpActionReference.action.performed += OnJump; } void Update() { var center = _xrRig.cameraInRigSpacePos; _collider.center = new Vector3(center.x, _collider.center.y, center.z); _collider.height = _xrRig.cameraInRigSpaceHeight; } private void OnJump(InputAction.CallbackContext obj) { if (!IsGrounded) return; _body.AddForce(Vector3.up * jumpForce); } Four errors received from using the above code: Assets\playercontroller1.cs(11,13): warning CS0618: ‘XRRig’ is obsolete: ‘XRRig has been deprecated. Use the XROrigin component instead.’ Assets\playercontroller1.cs(21,31): warning CS0618: ‘XRRig’ is obsolete: ‘XRRig has been deprecated. Use the XROrigin component instead.’ Assets\playercontroller1.cs(29,22): warning CS0618: ‘XRRig.cameraInRigSpacePos’ is obsolete: ‘cameraInRigSpacePos has been deprecated. Use the CameraInOriginSpacePos instead.’ Assets\playercontroller1.cs(31,28): warning CS0618: ‘XRRig.cameraInRigSpaceHeight’ is obsolete: ‘cameraInRigSpaceHeight has been deprecated. Use the CameraInOriginSpaceHeight instead.’
@alex_advanced
@alex_advanced Жыл бұрын
Hi Justin, great video! One question: Does the new Input System require using the OpenXR backend? Or can I use it just fine with the Oculus plug-in? I ask because Unity docs say that the Oculus Integration package isn't compatible with OpenXR at this time, but I do want to use the new Input System Thank you!!
@zima2352
@zima2352 Жыл бұрын
Hey Barnett, I had issues with the coding, for example tryping in serializedfield etc didn't pop up along with the majority of coding you where typing. I set-up/installed my Unity and VS coding program via another vr channels set-up tutorials (been hoping around leaning). Since everything is moving super quick with versions of these programs would it be possible to point me in the direction of the video you have for XR set-up? Can't imagine how hard must be to stay ontop of all the updates and versions coming out changing the terminology and ui of all the programs. Videos from 2 years ago you can easily see the mass amount of content updates
@InTheMindOfficial
@InTheMindOfficial Жыл бұрын
I will literally pay for you to help me with my project at this point tbh
@JustinPBarnett
@JustinPBarnett Жыл бұрын
You can download the code for the project to get it working!
@AzureWings_
@AzureWings_ 2 жыл бұрын
for the movement, how can i change the speed? I kind of want a faster paced game but a sprint button could work too. Also this tutorial worked on 2021.3!
@nocoreal
@nocoreal 7 ай бұрын
Update function gives me this Error: NullReferenceException: Object reference not set to an instance of an object have i done something wrong
@vjyochee
@vjyochee 3 жыл бұрын
if we leave away the variable "IsGrounded", this script could be used for flying?
@JustinPBarnett
@JustinPBarnett 3 жыл бұрын
you could jump infinite times!! so yea! lol
@vjyochee
@vjyochee 3 жыл бұрын
@@JustinPBarnett wellwell, some kind of "fly to where HMD is looking at" feature would be cool. maybe in one of the next tutorials? Btw. really good tutorials, great to follow along!
@termi5666
@termi5666 2 жыл бұрын
I had a problem, and is that when playing it on the editor It worked just fine. But when building the game and playing it (the apk file), some actions didn't work. I was doing the tutorial with another action, for example: Click the Joystick. At first, I used the default action called and it worked on the editor play mode but not the build. Then I added another binding for my specific controller (Quest2) called and worked perfectly!!!
@IfionfomyYojin
@IfionfomyYojin 2 жыл бұрын
In my case the code only works if I add jumpActionReference.asset.Enable(); into the PlayerController.Start method. For reference: Unity 2020.3.19f1, Input System: 1.0.2
@JustinPBarnett
@JustinPBarnett 2 жыл бұрын
Yes you’ll need to enable the asset first
@loukenart
@loukenart 3 жыл бұрын
nice video Justin! i actually own a quest 2, so im exited to see what you will make with it in the future! is there a way to test the game on rift (wich i also have) and then build it on to quest 2? Greetings from Edvard
@JustinPBarnett
@JustinPBarnett 3 жыл бұрын
Yes! You'll have to use the settings in this video to test on rift and then in the next (or one after?) video I'll post about how to build for the quest
@keremaslan1988
@keremaslan1988 2 жыл бұрын
Hey, I want to move with my left joystick of my Oculus. How can I set it on Input actions menu?
@JustinPBarnett
@JustinPBarnett 2 жыл бұрын
Check out my "How to Move" tutorial!
@arfiandi3998
@arfiandi3998 2 жыл бұрын
I used to make handcontroller from your tutorial, then I combined it with this script so I could get jump and hand controller but the rigidbodies made me move so fast, how to fix it ? thank you
@JustinPBarnett
@JustinPBarnett 2 жыл бұрын
Join the discord and we can help you troubleshoot!
@SwamySwank
@SwamySwank 2 жыл бұрын
When i did the update code you did to update the collider i went throught the wall when my camera went through it, do you know a fix, im using 2021.3.4f1
@asdasdaqwewq9880
@asdasdaqwewq9880 2 жыл бұрын
I did everything you do in the video but I go through walls so collision is not working properly (I tried to set it to Continuous) What should I do?
@JustinPBarnett
@JustinPBarnett 2 жыл бұрын
Join the discord and we can help you troubleshoot!
@WebHead45.
@WebHead45. 2 жыл бұрын
Hi i followed your video for the jump and now when i play my game i fly in the sky without pressing any buttons
@JonTopping
@JonTopping 2 жыл бұрын
Super helpful! And that trick at 10:00 was awesome, didn't know that, and I'll definitely be using it from now on. I had a few issues if you don't mind helping me out. 1. Biggest one, at 13:08, there's no such thing as an XRRig for my coding, it's giving me an error. Did they change the term recently? 2. When I do the raycast grounded check, it works when I'm on a regular plane, but it doesn't work when I walk up a hill with a mesh collider. The mesh collider works great, and I walk up the hill fine, but I can't jump, because it's not returning the bool IsGrounded correctly or something. 3. Lots of VR games have up on the right stick work as jump. How would you set the button to that? I don't see anything in the list that looks like it could be that. Furthermore, what if I want left/right on the right stick to rotate, BUT if you're holding grab, then I want it to do something else (like switch equipped weapon)? 4. Also, when I move having the capsule collider working (got that working btw!) if I walk into stuff, I get huge jittering. It's like it's trying to move into it, but being pushed back, every update. It's terrible, lol. How do you fix that? 5. I'm also getting the jittering issue when I jump, where as I fly through the air everything jitters. I turned on interpolation with rigidbody, and that helped, but only if I'm only jumping, the moment I move while jumping it ruins the jump really badly, jittering, and even making me not jump as high. Extrapolate works better, but still jittery, and for some reason the wall issue is now so bad that I can jitter through walls if I keep pushing it. 6. It looks like this whole action input system is great, as you said, for having multiple types of input work with the same code (so VR, gamepad, keyboard, all with just saying "jump"). How would you set up all the other parts of having jump work with the other inputs? 7. Now that I have a capsule collider on my character, if I grab that little box, it absolutely freaks out the capsule collider, and I go flying around the world crazily. How do you make objects you grab not interact with your personal collider?
@JustinPBarnett
@JustinPBarnett 2 жыл бұрын
Join the Discord and we can help you out with your questions!
@tacticalmythic7945
@tacticalmythic7945 2 жыл бұрын
I am getting the same jittery when I jump and use continuous turn script. I asked in Discord, but no one is responding after days of it being in the dev help page :(
@mathiolia5877
@mathiolia5877 Жыл бұрын
Hi i want to make a Multiplayer setup , not locally, but globally using the Photon, so how can i do that ? my requirement is one person uses PC and one Person uses Quest, how to do that, Mock HMD Maybe? pl advice and guide
@canadamanvr3345
@canadamanvr3345 2 жыл бұрын
My code just doesn't work, I've tried every way I need help Maybe sending the code (I cant pay for patreon due to card being suspended)
@JustinPBarnett
@JustinPBarnett 2 жыл бұрын
Join the discord and we can help you troubleshoot!
@rasmushenkel4444
@rasmushenkel4444 2 жыл бұрын
Hey. Great video! I've got the jump to work, but for some reason the raycast returns false if i'm standing on anything but a plane. I would like to be able to jump from a box collider... What am i doing wrong? Thanks
@JustinPBarnett
@JustinPBarnett 2 жыл бұрын
Maybe try extending the raycast a bit more or making sure the other ground objects are being recognized in the raycast layermask
@kirbymybae
@kirbymybae 3 жыл бұрын
The player controller script just has the script in it. I rechecked the code and I dont think our languages match if that can even happen. Can you help me out?
@JustinPBarnett
@JustinPBarnett 3 жыл бұрын
What language are you using?? Unity only uses C#
@thameesmohamed3582
@thameesmohamed3582 Жыл бұрын
bro in unity i can't see that file that name was XRI LeftHand/jump ,kindly help me bro
@Dustyflyguy
@Dustyflyguy 3 жыл бұрын
thanks :D
@JustinPBarnett
@JustinPBarnett 3 жыл бұрын
You're welcome!
@kamsin007
@kamsin007 3 жыл бұрын
Great Tutorial. Can you please do a Tutorial for Google Cardboard in version 2021.2 Beta. Thanks :)
@JustinPBarnett
@JustinPBarnett 2 жыл бұрын
Ehhhh doubt it 😬 Google cardboard is getting phased out
@ultimav3868
@ultimav3868 Жыл бұрын
Can you put the code in the description?
@JustinPBarnett
@JustinPBarnett Жыл бұрын
There's a link in the description you have get it at!
@connorgibson3933
@connorgibson3933 3 жыл бұрын
having this issue when I press play where it doesn't play on my Oculus Quest 1 headset and takes in no input. However, when I go back to the oculus sdk in the plugin manager everything works fine. Anyone found any solutions for this. also working on a laptop Found a half fix for unity editor where I change the OpenXR runtime in project settings but that only makes it work in the editor.
@JustinPBarnett
@JustinPBarnett 3 жыл бұрын
I'm actually posting a video on Wednesday about how to build and test to the Quest!
@cammcream193
@cammcream193 3 жыл бұрын
Awesome tutorial! Loved it but when jumping the scene goes all jittery (jumping and falling) know a fix?
@JustinPBarnett
@JustinPBarnett 2 жыл бұрын
Join the discord if you're still having issues and we can help you troubleshoot!
@lint_animations4372
@lint_animations4372 3 жыл бұрын
I have a problem with grabbing objects, when i grab them they act like a jet pack and psh me in the opposite direction
@JustinPBarnett
@JustinPBarnett 3 жыл бұрын
Try checking out my physics grab tutorial! The default xr interaction grab doesn't really work too well
@lint_animations4372
@lint_animations4372 3 жыл бұрын
@@JustinPBarnett thankyou sooo much i really thought you would never reply!
@WhoopyStick
@WhoopyStick 2 жыл бұрын
@@lint_animations4372 I was also experiencing this, I think its because both you and the object have a rigidbody. I actually dialed in the radius of my capsulecollider and made myself "skinnier" then it only happened if I brought the object close to my chest/body.
@pegsGamesVR
@pegsGamesVR 2 жыл бұрын
You will need to set your XR-Rig and other grabbable objects into their own separate layers. (upper right in the inspector, make new layers if non set) Then in edit->Project settings->Physics. Scroll down and uncheck the boxes where the XR-Rig/Grabbable check boxes (Whatever you call them) meet. This should mean they don't collide with each others, while still colliding with everything else.
@MuerteRico
@MuerteRico 2 жыл бұрын
@@pegsGamesVR I have the same issue. Tried everything - not working. I'm still flying away while grab and object :(
@REAL_R11
@REAL_R11 Жыл бұрын
Hi, so when I do this there is no rig there's only XR ORIGIN (the closest thing) and the console says there are 9 errors. I'm not sure because my code matched up BUT none of the precoded presets aren't there so I had to manually type all of it. Can you help? My code: using UnityEngine; using UnityEngine.InputSystem; [RequireComponent(typeof(Rigidbody))] public class playercontroler : MonoBehaviour { [SerializeField] private InputActionReference jumpActionReference [SerializeField] private jumpForce = 500.0f; private Rigidbody _body; private bool IsGrounded => Physics.Raycast( new Vector2(transform.position.x, transform.position y + 2.0f), Vector3.down, 2.0f); void Start() { _body = GetComponent(); jumpActionReference.action.performed += OnJump; } void Update() { } private void OnJump(InputAction.CallbackContext obj) { if (!IsGrounded) return; _body.AddForce(Vector3.up * jumpforce); } }
@InTheMindOfficial
@InTheMindOfficial Жыл бұрын
Sadly did not work at all for me, not sure what I'm doing wrong
@shimong1238
@shimong1238 2 жыл бұрын
I don't know why but it just doesn't work for me If I press A on my oculus quest 2 controller nothing happen It's the same thing for my animation. If I press the grip button it close my hand but not how I want it and if I press the trigger button, nothing happen );
@elbodomo8875
@elbodomo8875 2 жыл бұрын
hey buddy, for some reason it is bugged, so you have to set a specific action for the oculus touch controller where you did set the xr controller action
@hulkmunkeysmashdaily8620
@hulkmunkeysmashdaily8620 2 жыл бұрын
Hey Justin great vid. I am trying to add a jump function to my VR game but I get an error that says ‘CS0246; the type name space XRRig could not be found…’ does this mean XRRig is no longer being used in unity? Sorry I’m a super noob.
@JustinPBarnett
@JustinPBarnett 2 жыл бұрын
Oh they updated it to “XROrigin”, try that one!
@ThymeSoup
@ThymeSoup 2 жыл бұрын
How does the event system work for cases like the joysticks where you need some axis data? I want to do a custom character controller since the provided one does not work well with other physics. The subscribed function does have information about what called it however I don't see a way to get the joystick data from there. And once we have that joystick value, how can we keep track of the orientation of the camera? I noticed that nothing changes in the editor when I move my head.
@JustinPBarnett
@JustinPBarnett 2 жыл бұрын
All you need is to read the Vector2 or Vector3 value once that action is performed using value = reference.action.ReadValue();
@ThymeSoup
@ThymeSoup 2 жыл бұрын
@@JustinPBarnett Yep, that works, thank you. I was confused on how to get camera orientation but I guess the main camera does rotate but it won't show its rotation changing in the editor when running.
@eyalretter2354
@eyalretter2354 2 жыл бұрын
Hi Justin, Thank you very much for these videos. I am watching them and learn. How do I clean unity project ? I tried this tutorial. It didn't work. Every time I start my project I jump out of the project scene plane (ground). I couldn't fix this. I tried to revert and remove: I deleted the PlayerControl component, the XR jump interaction we add (and saved), rebuilt => still jumping out on startup. I deleted the *.cs file we wrote => still jumping out. cleaned the project cache (edit->properties cache) => doesn't work. Only deleting the Rigidbody and CapsuleColider I managed to get reid of the jump. I am building Android for my Oculus, Where are all the object files being saved? Why couldn't I clean this ? thanks Eyal
@JustinPBarnett
@JustinPBarnett 2 жыл бұрын
Join the discord if you're still having issues and we can help you troubleshoot!
@SigmaPhonkBabyGronk
@SigmaPhonkBabyGronk 3 жыл бұрын
Hey this tutorial is amazing but i have one problem. every time i jump and turn (with my joystick) , it crashes my game. do you know whats causing that? thanks!
@JustinPBarnett
@JustinPBarnett 3 жыл бұрын
Oh that's very odd... I'll look into it
@Landspyker
@Landspyker 2 жыл бұрын
I am only able to jump once but then I can't jump again. I put a debug log on the code to see in console if it's working and it is, it's saying I jumped every time I press the button but nothing is happening. Anyone able to help?
@Landspyker
@Landspyker 2 жыл бұрын
Now there's nothing happening at all. Not even in the debug log and I started from scratch and followed the tutorial from the start.
@SawTheAnoy
@SawTheAnoy Жыл бұрын
can u just add the script in the desription in typed it and it didnt work
@doomythedubstepfan
@doomythedubstepfan 3 жыл бұрын
hi my unity console keep getting an error (NullReferenceException: Object reference not set to an instance of an object) CS:32 My code using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.XR.Interaction.Toolkit; [RequireComponent(typeof(Rigidbody))] [RequireComponent(typeof(CapsuleCollider))] public class XRPlayerController : MonoBehaviour { [SerializeField] private InputActionReference JumpActionReference; [SerializeField] private float JumpForce = 500.0f; private Rigidbody _body; private XRRig _xrRig; private CapsuleCollider _collider; private bool IsGrounded => Physics.Raycast( new Vector2(transform.position.x, transform.position.y + 2.0f), Vector3.down, 2.0f); void Start() { _body = GetComponent(); _collider = GetComponent(); _xrRig = GetComponent(); JumpActionReference.action.performed += OnJump; } void Update() { var center = _xrRig.cameraInRigSpacePos; _collider.height = Mathf.Clamp(_xrRig.cameraInRigSpaceHeight, 1.0f, 3.0f); _collider.center = new Vector3(center.x, _collider.height / 2, center.z); } private void OnJump(InputAction.CallbackContext obj) { if (!IsGrounded) return; _body.AddForce(Vector3.up * JumpForce); } }
@JustinPBarnett
@JustinPBarnett 2 жыл бұрын
Join the discord and we can help you troubleshoot!
@guilhermedumatrindade4694
@guilhermedumatrindade4694 2 жыл бұрын
Hey Justin, how are ya? So, I was taking a look at the inputsystem docs and I couldnt really grasp a solution to this… I created a MaxForce float and wanted to gradually addforce while the button press is true and the force added since the first press is smaller or equal to the max force, but I’m not sure that’s doable with the inputsystem you used in this tutorial? I’m not really proficient in C# yet so this might be easier to implement than I’m imagining.
@guilhermedumatrindade4694
@guilhermedumatrindade4694 2 жыл бұрын
Basically a jedi jump, the longer you hold, higher it goes
@JustinPBarnett
@JustinPBarnett 2 жыл бұрын
For that you'd probably have to check in the update method every frame if the button is being pressed. If so, just increase the force a little bit.
@IcyStoneGaming
@IcyStoneGaming 2 жыл бұрын
Is this the same with 2021 install
@silverwolf5603
@silverwolf5603 3 жыл бұрын
I wrote the code the exact same way you did, but an error popped up and say that it couldn't find "XRRig". Any ideas on how I can fix this?
@JustinPBarnett
@JustinPBarnett 3 жыл бұрын
Sounds like you missed setting the XRRig either in your inspector or the start method
@jbg0801
@jbg0801 3 жыл бұрын
if you're still having this issue, you may notice that when he added the reference to the XR rig, it added at the top "using UnityEngine.XR.Interaction.Toolkit;" which he didn't seem to notice/mention. If you add that, it'll be fine.
@WhoopyStick
@WhoopyStick 2 жыл бұрын
I just fixed this same problem. When you start typing in XRRig there will be a green plus sign, when you click it there's a dropdown menu with the XRRig in it. I was about to sell my PC and move to Alaska. Hope this helps.
@tacticalmythic7945
@tacticalmythic7945 2 жыл бұрын
@@jbg0801 umm no its now called XrOrigin instead of XrRig
@jbg0801
@jbg0801 2 жыл бұрын
@@tacticalmythic7945 if that's changed in the FIVE MONTHS since I wrote that message, so be it
@kamuisw
@kamuisw 3 жыл бұрын
what IDLE are you using?
@JustinPBarnett
@JustinPBarnett 3 жыл бұрын
Jetbrains Rider
@therecbros9840
@therecbros9840 2 жыл бұрын
at 12:26 he looks high Only if you pause it
@loeweguckmal
@loeweguckmal 2 жыл бұрын
What programm are you using to edit your code? I have problems with mine.
@JustinPBarnett
@JustinPBarnett 2 жыл бұрын
JetBrains Rider. Highly recommend 👌
@loeweguckmal
@loeweguckmal 2 жыл бұрын
@@JustinPBarnett Thanks
@JustinPBarnett
@JustinPBarnett 2 жыл бұрын
@@loeweguckmal Sure thing! It's free for students
@damian3k
@damian3k 3 жыл бұрын
_collider.center = new Vector3(center.x, _xrRig.cameraInRigSpaceHeight / 2, center.z); works better ;D
@JustinPBarnett
@JustinPBarnett 2 жыл бұрын
Thanks!
@olivername
@olivername Жыл бұрын
hey I have defualt inputs only some are there do I need to add all the ones you got @Jusrtin P Barnett
Re-center your VR Player in Unity
19:51
Justin P Barnett
Рет қаралды 17 М.
5 Unity Assets for VR You Need to Know
9:55
Justin P Barnett
Рет қаралды 79 М.
مسبح السرير #قصير
00:19
سكتشات وحركات
Рет қаралды 11 МЛН
拉了好大一坨#斗罗大陆#唐三小舞#小丑
00:11
超凡蜘蛛
Рет қаралды 16 МЛН
Glow Stick Secret Pt.4 😱 #shorts
00:35
Mr DegrEE
Рет қаралды 18 МЛН
❌Разве такое возможно? #story
01:00
Кэри Найс
Рет қаралды 6 МЛН
Use Unity's Input System Like a Pro
24:48
Paridot
Рет қаралды 27 М.
VR Interactables: Everything You Need to Know!
25:34
Justin P Barnett
Рет қаралды 26 М.
I Paid Fiverr Game Developers to Make the Same Game
10:25
BadGameDev
Рет қаралды 683 М.
How to use TOUCH with the NEW Input System in Unity
24:11
samyam
Рет қаралды 68 М.
How To Start A VR Game In Unity 2021
25:07
Justin P Barnett
Рет қаралды 64 М.
The biggest lie in video games
15:18
AIA
Рет қаралды 1,8 МЛН
Smooth Scene Fade Transition in VR
23:19
Valem Tutorials
Рет қаралды 35 М.
VR Optimization and Performance Tips for Unity
14:22
VR with Andrew
Рет қаралды 50 М.
BEST Unity Tools to Get Started
5:25
samyam
Рет қаралды 10 М.
مسبح السرير #قصير
00:19
سكتشات وحركات
Рет қаралды 11 МЛН