cancel
Showing results for 
Search instead for 
Did you mean: 

Jitter moving a simple object using Unity in VR

ttgjou
Level 2
I have a problem that I don't know because there are so few people who suffer it too.
I am making a game where I need to move an object over the scene from one point to another using code.
The problem is that when I see the object move using the VR glasses, I see the movement as with jitter and the faster it moves, that jitter gets worse.
Note:
I use Unity 2019.1.14

The code is very simple:


****************************************************************************************
public class DesplazamientoPruebas : MonoBehaviour
{
    public Transform[] puntos;
    public int contador = 0;
    Vector3 posicion;
    // Start is called before the first frame update
    void Start()
    {
        Application.targetFrameRate = 90;

        posicion = puntos[contador].position;
    }

    // Update is called once per frame
    void Update()
    {


       if( Vector3.Distance(transform.position,puntos[contador].position)<2 )
        {
            
            contador++;
            if (contador > 1)
            {
                contador = 0;
            }
            posicion = puntos[contador].position;
       
        }
        transform.position = Vector3.MoveTowards(transform.position, posicion, 0.2f);

    }
}
**************************************************
This script is assigned to the object and I only observe how it moves when I start the game.

I have tried to:

  • Modify the time in the game preferences to leave it as 1/90 or 1/60.

  • Change all playerSetting parameters following the Oculus recommendations.

  • To move the object I tried Update () with time.deltatime
  1. FixedUpdate with Time.fixedDeltaTime
  2. LateUpdate with time.deltatime

  • I have tried as functions:
  1. Transform.Translate
  2. Vector3.Lerp
  3. Verctor2.MoveTowards

All with the same result . It doesn't happen to you?
I would appreciate a help because I can't think of what else to do.

Thank you very much!!

1 REPLY 1

FocusVRGames
Level 5
Hi

From the look on your code, your distance travelled on each update is too high.

I would look to use iTween instead as this will give you some finer control and result in smooth animations

Its free in the asset store
https://assetstore.unity.com/packages/tools/animation/itween-84

This is the website
http://pixelplacement.com/itween/index.php

Good luck
Mike