0
\$\begingroup\$

I created "rotate.cs" & attached it to a prefab which gets instantiated during play mode. The gameobject which spawns is supposed to rotate constantly. For some reason, it rotates only in scene view & not in game view. Note: I used play mode with oculus quest 2 in VR. I took off the headset to check whether the spawned gameobject's rotation was changing in the inspector or not & it was changing.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Rotate : MonoBehaviour
{

    // Start is called before the first frame update
    void Start()
    {

    }

    // Update is called once per frame
    void Update()
    {
        transform.Rotate(0f, 250 * Time.deltaTime, 0f, Space.Self);
    }
}

Here are the instantiated prefab's components & hierarchy: inspector window

\$\endgroup\$
2
  • 1
    \$\begingroup\$ I tested your code and it's working as intended. Can you show how your Prefab's hierarchy appears, and how you assigned the script in the editor? \$\endgroup\$
    – liggiorgio
    Commented Jul 6, 2022 at 12:48
  • \$\begingroup\$ @liggiorgio i just added a screenshot of the instantiated prefab's components & hierarchy in the post \$\endgroup\$
    – ahiyantra
    Commented Jul 6, 2022 at 13:29

1 Answer 1

0
\$\begingroup\$

I've been struggling with this too. It seems like there are conflicting scripts that also modify the transform of the reticle.

To work around this, I created a new prefab structured as follows:

  • An empty GameObject as the parent
  • The VR_Recticle_Circular as a child of this parent

I attached the rotation script to the child (VR_Recticle_Circular) to ensure it handles rotation independently, while the parent GameObject remains unaffected by any other potential scripts that have been interfering with the transform.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .