Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 Jun 22
sparklines
Close Help
  • 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 /
  • Help Room /
avatar image
0
Question by unity_Wt8tKN7YPFKM5A · Feb 14 at 09:59 AM · movementvrperformance optimization

Vector3.SmoothDamp movement gets stuck on Quest 2

I'm currently working with some fellow students on a VR experience where you move around in a kind of a floater/elevator that can move on the horizontal and vertical axis and aligns itself according to the destination. The whole thing actually already works very well and smoothly, at least on the computer, but standalone on the Quest2 the floater/elevator sometimes just gets stuck on the way to a destination and I don't know what the problem could be. I'm afraid it's somehow due to small framerate drops. Does anyone have a solution or suggestion on how to solve the problem? I'm also still quite a coding beginner and therefore my code is not optimal. Movement is done in the update.

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class FloaterSystem : MonoBehaviour
 {
     Vector3 startingPos;
     Quaternion startingRot;
     Transform targetObj;
     Transform previousTarget;
     Vector3 targetPos;
     Vector3 yOffset;
     float yOffsetValue = 1;
     Quaternion targetRot;
     Vector3 velocity = Vector3.zero;
     [Tooltip("A higher Number is slower!")][SerializeField] float elevatorSpeed = 70;
     //string playerTag = "Player";
     GameObject overviewInterface;
     GameObject werkeInterface;
     GameObject lebenInterface;
     bool floaterActivated = false;
     bool playerIsAttached = true;
 
 
     // Start is called before the first frame update
     void Start()
     {
         yOffset = new Vector3(0, yOffsetValue, 0);
         overviewInterface = transform.Find("Interfaces/Overview").gameObject;
         werkeInterface = transform.Find("Interfaces/Werke").gameObject;
         lebenInterface = transform.Find("Interfaces/Leben").gameObject;
         overviewInterface.SetActive(true);
         werkeInterface.SetActive(false);
         lebenInterface.SetActive(false);
 
         startingPos = transform.position; //save initial transform
         startingRot = transform.rotation;
         targetObj = transform;
         previousTarget = targetObj;
     }
 
     // Update is called once per frame
     void Update()
     {
 
         if (floaterActivated)
         {
             transform.position = Vector3.SmoothDamp(transform.position, targetPos, ref velocity, Time.deltaTime * elevatorSpeed);
             transform.rotation = Quaternion.Slerp(transform.rotation, targetRot, Time.deltaTime);
             //transform.rotation = Quaternion.RotateTowards(transform.rotation, targetRot, (elevatorSpeed/2) * Time.deltaTime);
 
 
             if (transform.position == targetPos)
             {
                 floaterActivated = false;
             }
         }
     }
 
     public void ChangeFloor(GameObject targetObject)
     {
         if (playerIsAttached)
         {
             previousTarget = targetObj;
             targetObj = targetObject.transform;
             targetPos = targetObj.position;
             targetRot = targetObj.rotation;
             floaterActivated = true;
         }
     }
 
     public void StartingFloor()
     {
         if (playerIsAttached)
         {
             targetPos = startingPos;
             targetRot = startingRot;
             floaterActivated = true;
         }
     }
 
     public void PreviousFloor()
     {
         if (playerIsAttached)
         {
             targetPos = previousTarget.position;
             targetRot = previousTarget.rotation;
             floaterActivated = true;
         }
 
     }
 
     private void OnTriggerEnter(Collider other)
     {
         //if (other.gameObject.tag == playerTag) //checks if player is near/on floater
         //{
         //    other.transform.parent = transform;
         //    playerIsAttached = true;
         //}
 
         if (other.gameObject.tag == "OverviewZone")
         {
             overviewInterface.SetActive(true);
             werkeInterface.SetActive(false);
             lebenInterface.SetActive(false);
         }
 
         if (other.gameObject.tag == "WerkeZone")
         {
             overviewInterface.SetActive(false);
             werkeInterface.SetActive(true);
             lebenInterface.SetActive(false);
         }
 
         if (other.gameObject.tag == "LebenZone")
         {
             overviewInterface.SetActive(false);
             werkeInterface.SetActive(false);
             lebenInterface.SetActive(true);
 
         }
     }
 
     private void OnTriggerExit(Collider other)
     {
         //if (other.gameObject.tag == playerTag) //checks if player leaves floater
         //{
         //    other.transform.parent = null;
         //    playerIsAttached = false;
         //}
     }
 }
   
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.

Follow this Question

Answers Answers and Comments

279 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 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 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

Unity VR - Held object lags behind hand position when moving. 2 Answers

How to move a player to a set position in vr 0 Answers

Plethora of Questions (Collisions give wrong names. imitating Crossy Road movement, is this expensive performance-wise, how would I lerp a small jump like in Crossy Road?) 0 Answers

VR game controller tracking doesn't work 0 Answers

SteamVR Teleport onto moving object 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