• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by ryjoe1312 · Jun 23, 2021 at 07:41 PM · oculus

Help changing from oculus integrations to XR input

Hello,

I was originally using the oculus integrations package but switched over to use the XR Rig, but in doing that one of my spawner scripts does not work. the script would work when I pressed the trigger. I have looked it up and dont really understand how to change the OVRInput over to XR Input. any help would be greatly appreciated! the spot I need to change is the OVRInput.Update() and OVRInput.GetDown(OVRInput.RawButton.RIndexTrigger))

 using System.Collections.Generic;
 using System.Collections;
 using UnityEngine.UI;
 using UnityEngine;
 using OVRTouchSample;
 
 public class spawner2 : MonoBehaviour
 {
     public UnitToggleGroup unitToggleGroup;
     public Transform[] spawnLocations;
 
     public float offset;
 
 
     public void Start()
     {
         offset = 0;
         OVRInput.Update();
     }
 
     public void Update()
     {
         if (OVRInput.GetDown(OVRInput.RawButton.RIndexTrigger))
         {
 
             if (unitToggleGroup.SelectedUnit != null)
 
             {
 
                 Quaternion rot = unitToggleGroup.SelectedUnit.transform.rotation;
 
                 unitToggleGroup.SelectedUnit.transform.rotation = Quaternion.identity;
 
                 Bounds bounds = GetBounds(unitToggleGroup.SelectedUnit);
 
                 unitToggleGroup.SelectedUnit.transform.rotation = rot;
 
 
 
                 if (offset != 0) offset += bounds.size.x / 2f;
 
 
 
                 Vector3 spawnOffset = new Vector3(offset, 0, 0);
 
                 Vector3 spawnOffset2 = (bounds.center - unitToggleGroup.SelectedUnit.transform.position); spawnOffset2.y *= -1;
 
                 Vector3 spawnOffset3 = new Vector3(0, bounds.extents.y, -bounds.extents.z);
 
                 spawnOffset += spawnOffset2 + spawnOffset3;
 
                 Debug.Log("Offset 1: " + 100f * spawnOffset2);
 
                 Debug.Log("Offset 2: " + 100f * spawnOffset3);
 
                 Debug.Log("Total offset vector: " + 100f * spawnOffset);
 
 
 
                 GameObject unit = Instantiate(unitToggleGroup.SelectedUnit, spawnLocations[0].transform.position + spawnOffset, Quaternion.Euler(0, 180, 0)) as GameObject;
 
 
 
                 //After we spawn, move the offset over again by half the size
 
                 offset += bounds.size.x / 2f;
 
 
 
                 Debug.Log("New offset is: " + offset);
 
             }
         }
     }
 
 
 
     public Bounds GetBounds(GameObject go)
 
     {
 
         //This will add together all of the bounds of the child objects so we can get the total size
 
         Bounds bounds = new Bounds();
 
         Renderer[] renderers = go.GetComponentsInChildren<Renderer>();
 
 
 
         if (renderers.Length == 0) return bounds;
 
         else bounds = renderers[0].bounds;
 
 
 
         foreach (Renderer r in renderers)
 
         {
 
             bounds.Encapsulate(r.bounds);
 
         }
 
         Debug.Log("Total bounding box: " + bounds);
 
 
 
         return bounds;
 
     }
 }
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

119 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

the coordinates of maincamera are changed wrongly. 0 Answers

Use Oculus Quest without steamvr,Project needs SteamVr despite using Oculus XR 0 Answers

Unity 3D with Oculus Rift? 2 Answers

Awesomium package + oculus package = nothing is working 1 Answer

add a "tablet" to a 3d space 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges