Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Question Character Size Goes Higher When Moving

Discussion in 'VR' started by creeperfrenzy28, May 31, 2021.

  1. creeperfrenzy28


    Dec 22, 2018
    Hi all. So, I'm new to Unity and am trying to make a VR Game for the Oculus Quest 2. I made one before and it turned out fine so I started a new project. All was going well until I tested it. I was the height I set myself to, but then I started walking and my height went way taller then I would have ever set. I don't think it's my moving code as this didn't happen in the other project. Here is my moving code:
    Code (CSharp):
    1. using System;
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. using UnityEngine;
    5. using UnityEngine.XR;
    6. using UnityEngine.XR.Interaction.Toolkit;
    8. public class mover : MonoBehaviour
    9. {
    10.     private InputDevice _device;
    11.     private CharacterController _character;
    12.     private Vector2 _inputAxis;
    13.     private GameObject _camera;
    15.     private void Start()
    16.     {
    17.         _device = InputDevices.GetDeviceAtXRNode(XRNode.LeftHand);
    18.         _character = GetComponent<CharacterController>();
    19.         _camera = GetComponent<XRRig>().cameraGameObject;
    20.     }
    22.     private void Update()
    23.     {
    24.         _device.TryGetFeatureValue(CommonUsages.primary2DAxis, out _inputAxis);
    26.         var inputVector = new Vector3(_inputAxis.x, Physics.gravity.y, z: _inputAxis.y);
    27.         var inputDirection = transform.TransformDirection(inputVector);
    28.         var lookDirection = new Vector3(x:0, y:_camera.transform.eulerAngles.y, z:0);
    29.         var newDirection = Quaternion.Euler(lookDirection) * inputDirection;
    31.         _character.Move(newDirection * Time.deltaTime * 1f);
    32.     }
    33. }
    After Moving.png Before Moving.png
    Any ideas? I have done research and can't find anything.
    Also, if there is a way to make it so when I touch the floor, my in game hands do too, that would be great.
    Thanks in regards.
  2. vrpooln


    Aug 31, 2021
    I've seen the answer to this in an earlier thread, I'll try to find it again. i already did but with no success, maybe I'll get to it.

    Did you find anything meanwhile? I see this thread is pretty old