So I was wondering how would i go about getting an objects rotation (which changes alot of the time) and lets say something simple like on click send the object down its relative/local -z axis…
so basically send the character backwards no matter what or where its rotation is?
I managed to have a go and got it to work but only when facing z or -z the x axis is completely screwed tho any ideas or easier way?
const object = sceneExport.getObjectByName( "player" );
const dirToPlayer = this._FindPlayer();
const controlObject = object;
const _Q = new THREE.Quaternion();
const _A = new THREE.Vector3();
const _R = controlObject.quaternion.clone();
const m = new THREE.Matrix4();
m.lookAt(
new THREE.Vector3(0, 0, 0),
dirToPlayer,
new THREE.Vector3(0, 1, 0));
_R.setFromRotationMatrix(m);
controlObject.quaternion.copy(_R);
this._parent.SetQuaternion(this._target.quaternion);
thanks guys