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?
Asked
Active
Viewed 757 times
0
-
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 07 '18 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 07 '18 at 18:38
-
Did you try not attaching it? – DMGregory Dec 07 '18 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 07 '18 at 19:26
1 Answers
0
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 by applying forces/torques to the rigidbody instead, to minimize teleportation artifacts. I have previous answers showing how to do this with velocity for translation and torque for rotation.

DMGregory
- 134,153
- 22
- 242
- 357