How To Prevent Cheating in Your VR Game!

Sdílet
Vložit
  • čas přidán 21. 07. 2022
  • Would you happen to know how to prevent cheating in your VR game?! The XR Interaction Toolkit provides a very easy-to-set up locomotion system, BUT players can easily cheat by walking through walls. In this video, I'll show you how to prevent that from happening!
    📺 Watch Next: • What Do I Need to Beco...
    🥽 Enroll in the (now FREE) VR Creator Academy: skool.com/vrcreatoracademy
    #meta #oculus #vr

Komentáře • 36

  •  Před rokem +4

    Another trick is to add an effect. In a game that I'm developing with a friend of mine, we add procedural vignette effect that gets stronger the closer you are to the wall.

  • @livjonsson124
    @livjonsson124 Před rokem +1

    Finally!!! I have been looking so long for this!
    If I could make a wish for a tutorial it would also be for a video that goes through how to not be able to break hinges on Doors and drawers when pushing on to them with an object with collider.

  • @Dominik-K
    @Dominik-K Před rokem

    This was helpful indeed, thanks a bunch

  • @JustinPBarnett
    @JustinPBarnett  Před rokem +3

    Download the Project (for FREE): www.vrcreators.io/codedownloads

  • @user-uo2jp6ej9s
    @user-uo2jp6ej9s Před rokem +1

    this is very helpful thank you

  • @connorwawryk4921
    @connorwawryk4921 Před rokem +1

    great video do you mind make a video on how to make a vr roller coaster

  • @lucaspicanco9649
    @lucaspicanco9649 Před rokem +1

    Justin could you make a video on how to make a VR grappling gun?

  • @piratemin_vr
    @piratemin_vr Před rokem

    Great video, very useful. Out of curiosity, what is the difference between inversetransformpoint and just getting the camera.transform.localposition?
    Apologies if that's a dumb question!

  • @DDoesGames
    @DDoesGames Před rokem

    Hi, so i checked your physical grab video, but i was having issues. But i really checked that video for the weighted grab, but im wondering how i can do that with a simpler format? Thanks for making great tutorials

  • @thaFoxy
    @thaFoxy Před rokem

    you should make a Hand poser Tutorial for unity XR Interaction Toolkit, it would be super helpful!

  • @PatrickHogenboom
    @PatrickHogenboom Před rokem +4

    The crouch bit is great. But I don't like blocking the worldspace movement of the player, that's a big no-no and can cause nausea.
    My solution to this problem is to black out the player's view when he/she leans through a wall in meat-space.
    This is detected by shooting rays from the player controller to the corners of the camera's near frustum.
    If anything obstructs those rays, the screen goes black.

    • @livjonsson124
      @livjonsson124 Před rokem

      That sounds good 🙂 What code do you need to be able to fade to black instead of blocking? Any suggestion what I could start with for that? Beside the things you already described?

    • @PatrickHogenboom
      @PatrickHogenboom Před rokem +1

      @@livjonsson124 In our previous implementation we were using VRTK, it has a VRTK_HeadsetFade class
      We're in the process of migrating to URP + OpenXR and there I'd use a ScriptableRendererFeature
      Here's a tutorial with code on it czcams.com/video/OGDOC4ACfSE/video.html

    • @livjonsson124
      @livjonsson124 Před rokem

      @@PatrickHogenboom thanks! I'll look into that!

    • @Corysia
      @Corysia Před rokem

      I partially agree with you. Yes, it can cause nausea. And actually trying to walk thru a real wall can cause real pain. ;) I've done both methods, pushback and blackout. What I don't like about the blackout one is that it breaks the immersion more for me (personal preference, I know). Also, I can get "lost" without some sort of signpost pointing me back to a valid play-space location. Unreal has a nice trick where you can add a message in there, too. Skyrim VR does this particular method. Ultimately, you have to select what's best for your game -- or provide both and let your players choose which they find is better. Maybe I'll put together an example with a "sign post", too.

  • @Corysia
    @Corysia Před rokem

    An important addendum: If you plan to use AddForce on your character, perhaps for jumping, you shouldn't use a Character Controller. Simply swap it out for a Capsule Collider and AddForce will work properly.

  • @FernwehRS
    @FernwehRS Před rokem

    Is there a way to smoothly reposition the character? Following this method does stop the wall clipping but it does it by instantly moving the player, instead of smoothly moving them back. This jumpy motion feels very odd.

  • @pandaa1485
    @pandaa1485 Před rokem

    The crouching is having a weird behaviour where i will get half way inside the object above my head than get spit out

  • @mattdway
    @mattdway Před rokem

    Great video. I love this concept and was actually researching how to do something like this a few weeks back with a project I have. However, my project is in Unity 2020.3.23f1 using the XR Interaction Toolkit 1.0.0-pre.6, which uses the now deprecated XR Rig instead of XR Origins. To simply update the XR Interaction Toolkit from 1.0 to 2.0 would break a lot of things in my project.
    Using the namespace UnityEngine.XR.Interaction.Toolkit; I referenced the XRRig component instead of XROrigin in Justin's code.
    However, this produced two errors that refer to definitions that apparently don't exist with the XR Rig: .Camera and .CameraInOriginSpaceHeight.
    Line 24 of my code var centerPoint = transform.InverseTransformPoint(_xrRig.Camera.transform.position); is producing the console error:
    Assets\Scripts\RoomScalePlayerControllerFix.cs(24,66): error CS1061: 'XRRig' does not contain a definition for 'Camera' and no accessible extension method 'Camera' accepting a first argument of type 'XRRig' could be found (are you missing a using directive or an assembly reference?)
    and line 22 of my code: _character.height = _xrRig.CameraInOriginSpaceHeight + 0.15f; is producing the console error:
    Assets\Scripts\RoomScalePlayerControllerFix.cs(22,36): error CS1061: 'XRRig' does not contain a definition for 'CameraInOriginSpaceHeight' and no accessible extension method 'CameraInOriginSpaceHeight' accepting a first argument of type 'XRRig' could be found (are you missing a using directive or an assembly reference?)
    Would anyone here know how to re-write these statements so that they make sense with the XR Rig? Here is the entirety of the code.
    Thanks much!
    using UnityEngine;
    using UnityEngine.XR.Interaction.Toolkit;
    [RequireComponent(typeof(CharacterController))]
    [RequireComponent(typeof(XRRig))]
    public class RoomScaleFix : MonoBehaviour
    {
    CharacterController _character;
    XRRig _xrRig;
    void Start()
    {
    _character = GetComponent();
    _xrRig = GetComponent();
    }
    void FixedUpdate()
    {
    _character.height = _xrRig.CameraInOriginSpaceHeight + 0.15f;
    var centerPoint = transform.InverseTransformPoint(_xrRig.Camera.transform.position);
    _character.center = new Vector3(
    centerPoint.x,
    _character.height / 2 + _character.skinWidth, centerPoint.z);
    _character.Move(new Vector3(0.001f, -0.001f, 0.001f));
    _character.Move(new Vector3(-0.001f, -0.001f, -0.001f));
    }
    }

    • @mattdway
      @mattdway Před rokem

      I was able to get help with the two XR Rig properties needed in another forum. Those removed my two compile errors and allowed me to successfully play test this change. I'm happy to report this is working perfectly.
      Should anyone be using an a version of the XR Interaction Toolkit that is pre-version 2 here are the changes I had to make in order to adapt this script:
      using UnityEngine;
      using UnityEngine.XR.Interaction.Toolkit;
      [RequireComponent(typeof(CharacterController))]
      [RequireComponent(typeof(XRRig))]
      public class RoomScalePlayerControllerFix : MonoBehaviour
      {
      CharacterController _character;
      XRRig _xrRig;
      // Start is called before the first frame update
      void Start()
      {
      _character = GetComponent();
      _xrRig = GetComponent();
      }
      void FixedUpdate()
      {
      _character.height = _xrRig.cameraInRigSpaceHeight + 0.15f;
      var centerPoint = transform.InverseTransformPoint(_xrRig.cameraGameObject.transform.position);
      _character.center = new Vector3(
      centerPoint.x,
      _character.height / 2 + _character.skinWidth, centerPoint.z);
      _character.Move(new Vector3(0.001f, -0.001f, 0.001f));
      _character.Move(new Vector3(-0.001f, -0.001f, -0.001f));
      }
      }

  • @starbuck3980
    @starbuck3980 Před rokem

    In Unity 2018 i could just use rigidbody and colliders to avoid going through walls now with the XR interaction toolkit doesnt work

  • @IMDBfredisreallydead
    @IMDBfredisreallydead Před rokem

    I love this as a solution but I would love to learn how one might set this to only be in effect when colliding with walls and not just any collider in the area. As is this makes it nearly impossible to lean over a table or other object with collision, in order to pick something up.
    I’ve tried playing around with code modification and a collider tag check clause that exits the script when that tag doesn’t match (which killed my FPS and crashed the editor) and I’ve tried a more low tech approach, by using the physics matrix to keep that character controller from colliding with certain non-wall layers, then using a different collider to try and fix it so that I don’t clip through those non wall objects, also not very affective. Lastly I tried making the character controller more of a head collision than whole body, but I ran into issues when setting this up too.
    Maybe a follow up video?
    I’d also love to see how implementing an effect (vignette) to this might work and if the bouncing is still necessary to ensure the person can’t find their way through a wall.

    • @sdhority
      @sdhority Před rokem +1

      Just a thought for you, you'll have to test it yourself;
      Make a bool called hittingWall or something in the RoomScaleFix script. Place the character.Move call within fixed update inside an if statement that checks for hittingWall to be true.
      Then add OnCollisionEnter and OnCollisionExit methods to RoomScaleFix.
      In collision enter do an if using collision.CompareTag("Wall"), just a typical tag check, and if true set the hittingWall bool to true.
      In collision exit use the same if statement but set hittingWall to false.
      Then make sure to tag any object you want to not be able to lean IRL through with a "Wall" tag.
      Just thoughts off the top of my head but this should keep the character.Move call (the micro-vibration) from recentering the character controller UNLESS it's hitting something tagged as a wall.
      Good luck!

    • @IMDBfredisreallydead
      @IMDBfredisreallydead Před rokem

      @@sdhority Your suggestion worked perfectly! Thank you!
      using UnityEngine;
      using UnityEngine.XR.Interaction.Toolkit;
      [RequireComponent(typeof(CharacterController))]
      [RequireComponent(typeof(XRRig))]
      public class RoomScalePlayerControllerFix : MonoBehaviour
      {
      CharacterController _character;
      XRRig _xrRig;
      private bool wallCheck;
      // Start is called before the first frame update
      void Start()
      {
      _character = GetComponent();
      _xrRig = GetComponent();
      }
      void OnTriggerEnter(Collider other)
      {
      if (other.gameObject.tag == "Wall")
      {
      // ReloadCurrentScene();
      wallCheck = true;
      Debug.Log(wallCheck);
      }
      else
      {
      wallCheck = false;
      }
      }
      void FixedUpdate()
      {
      _character.height = _xrRig.cameraInRigSpaceHeight + 0.15f;
      var centerPoint = transform.InverseTransformPoint(_xrRig.cameraGameObject.transform.position);
      _character.center = new Vector3(
      centerPoint.x,
      _character.height / 2 + _character.skinWidth, centerPoint.z);

      if(wallCheck==true)
      {
      _character.Move(new Vector3(0.001f, -0.001f, 0.001f));
      _character.Move(new Vector3(-0.001f, -0.001f, -0.001f));
      }
      }
      }

    • @sdhority
      @sdhority Před rokem

      @@IMDBfredisreallydead Awesome! Glad to hear that worked for you 😁.
      Cheers mate 🍻 good luck out there with your future dev adventures!

  • @starbuck3980
    @starbuck3980 Před rokem

    Tried in Unity 2021 and doesnt work, when i move physically and go through wall virtually it suddenly jumps many meters away

  • @PG13park
    @PG13park Před rokem +1

    What’s a good easy way to stop modding?

    • @teemuleppa3347
      @teemuleppa3347 Před rokem +1

      Modding should be supported not stopped, wth

  • @adhochero6619
    @adhochero6619 Před rokem

    If this is about room space cheating I have been working LONG on this problem and I think I have the best solution…

    • @blockify
      @blockify Před rokem +1

      Bruh why you tease…

    • @adhochero6619
      @adhochero6619 Před rokem +1

      @@blockify cause I never got around to watching this video all the way through. but the jist of what I did was:
      make a sphere collider and a capsule collider, the sphere following the head and the capsule follow the body and well as adjusting the center and height to account for the player crouching. also they have rigid bodies and use physics to move so collision work right.
      if the sphere collides with a solid object && the head move too far from the center of the sphere the player is moved back to be repositioned in the center, the capsule and body do something similar but at a further distance allowing the player so lean over things like a desk with out getting pushed back.
      this works for if the player trying to forcefully walk through a wall and or stand up through a low ceiling. also it doesn't just stop the player from moving as the lack of movement against the environment will cause nausea, thus the instant push back keeps the players direction movement steady, while still eliminating play space cheating.
      there is a bit more too it but its a lot to type.

  • @speedy345
    @speedy345 Před rokem +2

    First.

  • @tylerstafford7636
    @tylerstafford7636 Před rokem

    Everytime i try to make a unity build i get this error, this is a brand new unity and new hub I just redownloaded them just in case. But it says “FileNotFoundzException: Failed to find $C:/users/desktop/2021.3.6f1/Editor/Data/PlaybackEngines/AndroidPlayer/Tools\GradleTemplates\mainTemplate.grade