public virtual void ApplyKeepUp() { if (!_keepUp) { return; } Quaternion target; if (_upReferenceObject == null) { target = ExtRotation.TurretLookRotation(_toMove.rotation, _upReference); } else { if (_keepUpGalaxyOriented) { target = ExtRotation.TurretLookRotation(_toMove.rotation, _toMove.position - _upReferenceObject.position); } else { target = ExtRotation.TurretLookRotation(_toMove.rotation, _upReferenceObject.up); } } _toMove.rotation = ExtRotation.OwnSmoothDamp(_toMove.rotation, target, ref _refRotationUpVelocity, _dampingTimeRotation); }
private void DrawDirectionnalCylinder(Color color, Vector3 upCone, Vector3 choosenDirection) { Quaternion realdirection = ExtRotation.TurretLookRotation(choosenDirection, upCone); Vector3 realDirectionVector = realdirection * Vector3.forward; Debug.DrawLine(_p2 + realDirectionVector * _realRadius, _p1 + realDirectionVector * _realRadius, color); Debug.DrawLine(_p2 - realDirectionVector * _realRadius, _p1 - realDirectionVector * _realRadius, color); }
private Quaternion GetLastDesiredRotation(Vector3 dirRelativeInput, Vector3 up) { //Vector3 relativeDirection = entityAction.GetRelativeDirection().normalized; // Preserve our current up direction // (or you could calculate this as the direction away from the planet's center) //Vector3 up = objectToRotate.up; //Vector3 up = baseGravity.GetMainAndOnlyGravity(); // Form a rotation facing the desired direction while keeping our // local up vector exactly matching the current up direction. return(ExtRotation.TurretLookRotation(dirRelativeInput, up)); }
private void Update() { if (OverrideRotationUpGlobal) { if (!RotateWithTheParent) { ToLock.rotation = ExtRotation.TurretLookRotation(_saveRotation * Vector3.forward, Vector3.up); } else { ToLock.rotation = ExtRotation.TurretLookRotation(ToLock.forward, Vector3.up); } _saveRotation = ToLock.rotation; } if (RotateWithTheParent) { _saveRotation = ToLock.rotation; } else { ToLock.rotation = _saveRotation; } }
private void RotateUp() { Undo.RecordObject(_target.ToLock, "Rotate Up"); _target.ToLock.rotation = ExtRotation.TurretLookRotation(this.GetPropertie("_saveRotation").quaternionValue *Vector3.forward, Vector3.up); }
//here get the acceleration forward depending on the gravity public Vector3 GetActualDirForward() { Quaternion forwardDir = ExtRotation.TurretLookRotation(GetActualVelocityVector(), baseGravity.GetMainAndOnlyGravity()); return(forwardDir * Vector3.forward); }