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?

  • \$\begingroup\$ 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? \$\endgroup\$ – DMGregory Dec 7 '18 at 10:46
  • \$\begingroup\$ @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. \$\endgroup\$ – Debojeet Chatterjee Dec 7 '18 at 18:38
  • \$\begingroup\$ Did you try not attaching it? \$\endgroup\$ – DMGregory Dec 7 '18 at 18:52
  • \$\begingroup\$ 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 ? \$\endgroup\$ – Debojeet Chatterjee Dec 7 '18 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

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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