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.
  2. Dismiss Notice

Question How would I do rotation of a gameobject using the Controllers joystick(Vector 2)

Discussion in 'VR' started by jorn818, Jul 12, 2021.

  1. jorn818


    May 12, 2013
    So I have this vector 2 input called "Joyrotation" which is linked to my right joystick. I somehow need to be able to select a gameobject (the player parent object) and then being able to rotate this object by applying the vector 2 input "Joyrotation" im quite new to coding but any advice would be appreciated.

    What I know ; on Start() the gameobject needs to be selected and the input "Joyrotation" needs to be linked then Update() or UpdateInput, something like transform.rotation?

    and probably a variable for speed?? im not sure

    > something along the lines of

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using Valve.VR;
    using Valve.VR.InteractionSystem;

    public class ROTATOR2 : MonoBehaviour
    private Vector2 trackpad;
    private Vector3 rotateDirection;
    private CapsuleCollider CapCollider;
    private Rigidbody RBody;
    public float RotationSpeed;
    public SteamVR_Action_Vector2 RotationJoystick;
    public SteamVR_Input_Sources MovementHand;
    // Start is called before the first frame update
    void Start()
    CapCollider = GetComponent<CapsuleCollider>();
    RBody = GetComponent<Rigidbody>();


    // Update is called once per frame
    void Update()
    Rigidbody RBody = GetComponent<Rigidbody>();
    ??? Rotation?

    i just started learning the new Unity system my apologies if I come over as a noob I just want my playercontroller to work so i can walk around my map and XRRig doesnt support my WMR headset joysticks natively somehow.
    Last edited: Jul 12, 2021