How To Recenter in VR - Unity Tutorial

แชร์
ฝัง
  • เผยแพร่เมื่อ 10 พ.ย. 2024

ความคิดเห็น • 31

  • @yaoyaolu244
    @yaoyaolu244 หลายเดือนก่อน +1

    Works like a freaking charm! I'm working on a VR car showroom project and desperately needed a way to teleport to/out of the cockpit, and damn this tutorial worked for me.
    You can also disable the Character Controller if you wanna recenter/teleport to a higher/lower position without having your camera height reset to floor.
    declare - private CharacterController player;
    put this in Start() - player = GetComponentInChildren();
    and disable player in the Recenter() function - player.enabled = false;

  • @SamSamTutorialMan
    @SamSamTutorialMan ปีที่แล้ว +1

    Exactly what I needed! Thanks Valem!

  • @rahmatriyadi3201
    @rahmatriyadi3201 ปีที่แล้ว +2

    amazing tutorials, i hope the next valem tutorials is about adding sound in unity vr like footsteps or grab sound

    • @ValemTutorials
      @ValemTutorials  ปีที่แล้ว +1

      Thanks for the feedback. If you're interested in sound design in vr i already have a tutorial about it on the channel :D

  • @QuoteoftheDay-q7r
    @QuoteoftheDay-q7r ปีที่แล้ว

    everyday i always glad that valem always update his video, it helps me with my college about game and VR .

  • @EscHatchStudio
    @EscHatchStudio 5 หลายเดือนก่อน

    I couldn't solve this problem any other way - thank you so much for this great video!

  • @we.are.ready.official
    @we.are.ready.official ปีที่แล้ว +1

    Greetings from Ukraine! Thank you so much for this video. Everything is clear, understandable, and of high quality)

  • @TheARTofMining
    @TheARTofMining 8 หลายเดือนก่อน +3

    You do some great videos Valem thank you for them - HOWEVER IT DOES NOT SOLVE THE BIGGER ISSUE WITH VR ORIENTATION using XR.
    I have multiple scenes each that require the player to start facing a UI screen when the scene(s) loads.
    Despite hours of searching I have found no reliable solution as yet!
    I'm sure it's something the the XR interaction toolkit guys really should focus on.
    When you launch your VR game the XROrigin & Camera orientations of direction do not follow the splash screen direction(Unity Logo).
    I have tested starting my game, standing at a certain rotation angle while the splash screen appears. This puts me in whatever rotation. I then quit the app and physically turn 90 degrees and then start the app again.
    My orientation is turned to the corresponding 90 rotation, indicating that it does not orientate from the splash screen it orientates from your boundary setup I think!
    Wouldn't it be much simpler for the XR interaction toolkit to provide a RESET functionality? Such that when you load your game or a scene, a RESET would take the whole rig, block and disable the camera (instant FadeOut like teleport does),
    and then reset the camera Y rotation to zero and also zero out the camera position to the XROrigin position. Then re-enable the camera (quick Fadein like teleport does).
    This way you could set the XROrigin to a target (GO) position and rotation and the RIG would comply to those position and rotation values of said target.
    This code below puts the XROrigin in the correct target position, but if I walk away from center or physically turn that becomes a positional and rotational offset.
    [
    var rotationAngleY = MainCamera.transform.rotation.eulerAngles.y - targetTeleportLocation.transform.rotation.eulerAngles.y;
    PlayerXR_Origin.transform.Rotate(0,rotationAngleY,0);
    PlayerXR_Origin.transform.position = targetTeleportLocation.transform.position;
    ]
    What I need is to be able to recenter the CAMERA to the XROrigin *(simple in theory) but I have not discovered a way!
    InputTracking.Recenter - This only works with seated and standing experiences. Room scale experiences are not affected by Recenter and I see tons of issues with people trying to implement.
    Jeez how hard can it be for XR guys to integrate this?
    Rant over!
    Cheers

    • @yagneshkrishnan2544
      @yagneshkrishnan2544 6 หลายเดือนก่อน

      were you able to resolve it?

    • @TheARTofMining
      @TheARTofMining 6 หลายเดือนก่อน

      @@yagneshkrishnan2544 yes ,, using
      // Create a TeleportRequest with the target position and rotation
      TeleportRequest teleportRequest = new TeleportRequest()
      {
      destinationPosition = WayPointSetList[WayPointSet_CTR].transform.position,
      destinationRotation = targetRotation
      };
      // Queue teleportation request
      teleportationProvider.QueueTeleportRequest(teleportRequest);
      // Get the current camera rotation
      Quaternion cameraRotation = Quaternion.Euler(0f, MainCamera.transform.localEulerAngles.y, 0f);
      // Rotate the XR Rig's XROrigin to face the correct direction after teleportation, considering camera rotation
      PlayerXR_Origin.transform.rotation = targetRotation * Quaternion.Inverse(cameraRotation);

    • @TheARTofMining
      @TheARTofMining 3 หลายเดือนก่อน

      @@yagneshkrishnan2544 Yes using TeleportRequest

    • @kopefw
      @kopefw 2 หลายเดือนก่อน

      @@TheARTofMining
      // namespace
      using System;
      using UnityEngine.XR.Interaction.Toolkit.Locomotion.Teleportation;
      // inside a function
      TeleportRequest request = new();
      request.destinationPosition = target.position;
      request.destinationRotation = target.rotation;
      request.matchOrientation = MatchOrientation.TargetUpAndForward;
      teleportationProvider.QueueTeleportRequest(request);

  • @Saar58
    @Saar58 ปีที่แล้ว

    Great tutorial as always, couldn't find anything like that online! :>
    also worth mentioning - if you have UI following your XR camera (HUD), please make sure the scene "input system ui input module" has XR tracking origin, the script offset my ui intercation raycast without this reference.

  • @MythHead
    @MythHead ปีที่แล้ว +5

    Amazing!!! (first)

  • @ulyanchiksin5778
    @ulyanchiksin5778 ปีที่แล้ว

    Thank you, thank you so much!❤

  • @kelpez
    @kelpez ปีที่แล้ว

    NICE! Very useful!

  • @kelpez
    @kelpez ปีที่แล้ว

    Cant wait till the vr spectator camera tutorial

  • @НикитаМордик-к8ф
    @НикитаМордик-к8ф 2 หลายเดือนก่อน

    Thanks a lot, this help me a lot. But when recenter is complete, the collider of player is not align with recenter point.

  • @piratemin_vr
    @piratemin_vr ปีที่แล้ว

    Great vid, very useful but I'm sure you've posted a video very similar to this before - I literally followed it for my own project a few weeks ago!

    •  ปีที่แล้ว +1

      Justin P Barnett has a recenter position video maybe you are referencing that one.

    • @piratemin_vr
      @piratemin_vr ปีที่แล้ว +1

      @ You may be correct! Thanks!

  • @A_walk_in_the_park
    @A_walk_in_the_park 8 หลายเดือนก่อน

    Very nice tutorial, thank you. I have a problem though. The code positions camera very nicely to selected location, however, my CharacterController of the XR rig is still in a completely different location than the camera. How would one fix this?

  • @EstebanPabloPerez
    @EstebanPabloPerez 10 หลายเดือนก่อน

    Hi!, Is there any way to combine it with the re-centering button of the oculus controller? because when I hold it down it gives a strange rotation due to the fact that the XROrigin has been rotated to match the target transform and the oculus re-centering always places the camera towards the XROrigin's forward. Thank you very much.

  • @FileTh1rt3en
    @FileTh1rt3en ปีที่แล้ว

    I have a question in regards to additional buttons. You show how to add the Recenter button but how can we extend the Interactors/Interactables system so we can send more information to held or hovered objects by pressing other buttons. With the base XR Interaction Toolkit only Selected and Activated are supported but let's say you wanted to add the primary and secondary buttons to the InputActionAsset and then you wanted to be able to send those values to the interactable held, how would you go about doing that in a clean and reusable way? An example might be for a gun, you can grab it (select), you can shoot it (activate), but how would you allow primary button to be slide lock release and secondary button to be magazine drop?

  • @edoardopignatelli5128
    @edoardopignatelli5128 ปีที่แล้ว

    at the beginning of the video there is the driving simulator. Are you planning to make an updated tutorial of it?

  • @Ser_Nikos
    @Ser_Nikos ปีที่แล้ว +2

    Amazing tutorial! I had a problem: I didn't call the Recenter() function when I pressed the primary button. My goal was to call it in the Start method of the scene, but for some reason, I had a problem with the rotation. So, the solution I found was to create a simple coroutine that waits for around 0.1 seconds and then calls the Recenter function in the Start method. If anybody has another solution, please let me know.

    •  5 หลายเดือนก่อน

      I have the same problem and still looking for a solution beside a waitforseconds :-/

  • @wissalwissal3157
    @wissalwissal3157 ปีที่แล้ว

    Hi do you do personal trainings to beginners ?
    I’m interested

  • @matthewduncanson8744
    @matthewduncanson8744 ปีที่แล้ว +1

    Could you please make a tutorial on vr enemies that follow the player and do damage when close and if possible add making a health bar

  • @xr3y798
    @xr3y798 ปีที่แล้ว +1

    can you make a granade where you have to pull the pin to activate it

  • @jehadahmedmahmoud8754
    @jehadahmedmahmoud8754 ปีที่แล้ว +1

    how to make main menu in vr ?