In VR, I have the problem that when I want to grab an object and move it, I move it freely in space. That’s not right for my case. I want to move an object only in XZ position. Neither rotate nor move in the Y axis. Do you have a tip?
Original Post on Discord
by user 684154017479524352
Hi, you can create a small script that sets the position/rotation in onBeforeRender to the starting rotation/position on the axis.
Something like this:
export class LockAxis extends Behaviour {
private _startPosition? : Vector3;
start() {
this._startPosition = this.gameObject.position.clone();
}
onBeforeRender() {
this.gameObject.position.x = this._startPosition!.x;
this.gameObject.position.z = this._startPosition!.z;
}
}
And then add that to the dragged objects
THX👍
by user 684154017479524352