I'm trying to provide an illusion to the user by rotating the controller about an arbitrary axis in the LateUpdate() method. But this doesn't seem to be having any effect as the controller probably is constantly getting updated by its real world location. Is there any way to override its real world position and orientation with a transformation in script?

New contributor
Debojeet Chatterjee is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
  • Have you considered hiding the "real" controller object and adding your own "fake" visible object that follows the hidden object, with your extra rotation layered-on? – DMGregory Dec 7 at 10:46
  • @DMGregory Thanks for your suggestion. That's exactly what I tried to do next, but the fake object(attached to the SteamVR controller) also doesn't seem to obey the transforms I impose. – Debojeet Chatterjee Dec 7 at 18:38
  • Did you try not attaching it? – DMGregory Dec 7 at 18:52
  • Interesting, but then I'm not sure how I could make it follow the controller movements. Can you please suggest a way to do that @DMGregory ? – Debojeet Chatterjee Dec 7 at 19:26

I'd recommend hiding the "real" controller object, and creating your own visible object that matches its movements plus an offset you control, something like this:

public class FollowWithATwist : MonoBehaviour {

    // Set this to point at your controller
    public Transform objectToFollow;

    // Set this to the twist you want to apply
    public Quaternion extraRotation;


    void LateUpdate() {
         transform.position = objectToFollow.position;

         // This applies the twist in the controller's local space.
         // Flip the multiplication order if you want it applied in world space.
         transform.rotation = objectToFollow.rotation * extraRotation;
    }
}

If you want the object to interact with physics, then do this in FixedUpdate with velocity setting instead to minimize teleportation artifacts.

Your Answer

Debojeet Chatterjee is a new contributor. Be nice, and check out our Code of Conduct.

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.