Vector3 GetInfluencedAxis(AxisInfluenced axisInfluenced) { Vector3 axis = Vector3.zero; switch (axisInfluenced) { case AxisInfluenced.X: axis = Vector3.right; break; case AxisInfluenced.Y: axis = Vector3.up; break; case AxisInfluenced.Z: axis = Vector3.forward; break; case AxisInfluenced.XYZ: axis = Vector3.one; break; } return(axis); }
void DoAutoStabilisation(Transform axisTransform, AxisInfluenced axisInfluenced, float threshold, float speed, float startAngle) { float angle = 0; switch (axisInfluenced) { case AxisInfluenced.X: angle = axisTransform.localRotation.eulerAngles.x; break; case AxisInfluenced.Y: angle = axisTransform.localRotation.eulerAngles.y; break; case AxisInfluenced.Z: angle = axisTransform.localRotation.eulerAngles.z; break; } if (angle <= 360 && angle >= 180) { angle = angle - 360; } if (angle > startAngle - threshold || angle < startAngle + threshold) { float axis = 0; Vector3 stabAngle = Vector3.zero; if (angle > startAngle - threshold) { axis = angle + speed / 100f * Mathf.Abs(angle - startAngle) * Time.deltaTime * -1; } if (angle < startAngle + threshold) { axis = angle + speed / 100f * Mathf.Abs(angle - startAngle) * Time.deltaTime; } switch (axisInfluenced) { case AxisInfluenced.X: stabAngle = new Vector3(axis, axisTransform.localRotation.eulerAngles.y, axisTransform.localRotation.eulerAngles.z); break; case AxisInfluenced.Y: stabAngle = new Vector3(axisTransform.localRotation.eulerAngles.x, axis, axisTransform.localRotation.eulerAngles.z); break; case AxisInfluenced.Z: stabAngle = new Vector3(axisTransform.localRotation.eulerAngles.x, axisTransform.localRotation.eulerAngles.y, axis); break; } axisTransform.localRotation = Quaternion.Euler(stabAngle); } }
float GetStartAutoStabAngle(Transform axisTransform, AxisInfluenced axisInfluenced) { float angle = 0; if (axisTransform != null) { switch (axisInfluenced) { case AxisInfluenced.X: angle = axisTransform.localRotation.eulerAngles.x; break; case AxisInfluenced.Y: angle = axisTransform.localRotation.eulerAngles.y; break; case AxisInfluenced.Z: angle = axisTransform.localRotation.eulerAngles.z; break; } if (angle <= 360 && angle >= 180) { angle = angle - 360; } } return(angle); }
private float GetStartAutoStabAngle(Transform axisTransform, AxisInfluenced axisInfluenced) { float num = 0f; if (axisTransform != null) { switch (axisInfluenced) { case AxisInfluenced.X: num = axisTransform.localRotation.eulerAngles.x; break; case AxisInfluenced.Y: num = axisTransform.localRotation.eulerAngles.y; break; case AxisInfluenced.Z: num = axisTransform.localRotation.eulerAngles.z; break; } if (num <= 360f && num >= 180f) { num -= 360f; } } return(num); }
private void DoAutoStabilisation(Transform axisTransform, AxisInfluenced axisInfluenced, float threshold, float speed, float startAngle) { float num = 0f; switch (axisInfluenced) { case AxisInfluenced.X: num = axisTransform.localRotation.eulerAngles.x; break; case AxisInfluenced.Y: num = axisTransform.localRotation.eulerAngles.y; break; case AxisInfluenced.Z: num = axisTransform.localRotation.eulerAngles.z; break; } if (num <= 360f && num >= 180f) { num -= 360f; } if (num > startAngle - threshold || num < startAngle + threshold) { float num2 = 0f; Vector3 euler = Vector3.zero; if (num > startAngle - threshold) { num2 = num + speed / 100f * Mathf.Abs(num - startAngle) * Time.deltaTime * -1f; } if (num < startAngle + threshold) { num2 = num + speed / 100f * Mathf.Abs(num - startAngle) * Time.deltaTime; } switch (axisInfluenced) { case AxisInfluenced.X: euler = new Vector3(num2, axisTransform.localRotation.eulerAngles.y, axisTransform.localRotation.eulerAngles.z); break; case AxisInfluenced.Y: euler = new Vector3(axisTransform.localRotation.eulerAngles.x, num2, axisTransform.localRotation.eulerAngles.z); break; case AxisInfluenced.Z: euler = new Vector3(axisTransform.localRotation.eulerAngles.x, axisTransform.localRotation.eulerAngles.y, num2); break; } axisTransform.localRotation = Quaternion.Euler(euler); } }
void DoAngleLimitation(Transform axisTransform, AxisInfluenced axisInfluenced, float clampMin, float clampMax, float startAngle) { float angle = 0; switch (axisInfluenced) { case AxisInfluenced.X: angle = axisTransform.localRotation.eulerAngles.x; break; case AxisInfluenced.Y: angle = axisTransform.localRotation.eulerAngles.y; break; case AxisInfluenced.Z: angle = axisTransform.localRotation.eulerAngles.z; break; } if (angle <= 360 && angle >= 180) { angle = angle - 360; } //angle = Mathf.Clamp (angle, startAngle-clampMax, clampMin+startAngle); angle = Mathf.Clamp(angle, -clampMax, clampMin); switch (axisInfluenced) { case AxisInfluenced.X: axisTransform.localEulerAngles = new Vector3(angle, axisTransform.localEulerAngles.y, axisTransform.localEulerAngles.z); break; case AxisInfluenced.Y: axisTransform.localEulerAngles = new Vector3(axisTransform.localEulerAngles.x, angle, axisTransform.localEulerAngles.z); break; case AxisInfluenced.Z: axisTransform.localEulerAngles = new Vector3(axisTransform.localEulerAngles.x, axisTransform.localEulerAngles.y, angle); break; } }
private void DoAngleLimitation(Transform axisTransform, AxisInfluenced axisInfluenced, float clampMin, float clampMax, float startAngle) { float num = 0f; switch (axisInfluenced) { case AxisInfluenced.X: num = axisTransform.localRotation.eulerAngles.x; break; case AxisInfluenced.Y: num = axisTransform.localRotation.eulerAngles.y; break; case AxisInfluenced.Z: num = axisTransform.localRotation.eulerAngles.z; break; } if (num <= 360f && num >= 180f) { num -= 360f; } num = Mathf.Clamp(num, 0f - clampMax, clampMin); switch (axisInfluenced) { case AxisInfluenced.X: axisTransform.localEulerAngles = new Vector3(num, axisTransform.localEulerAngles.y, axisTransform.localEulerAngles.z); break; case AxisInfluenced.Y: axisTransform.localEulerAngles = new Vector3(axisTransform.localEulerAngles.x, num, axisTransform.localEulerAngles.z); break; case AxisInfluenced.Z: axisTransform.localEulerAngles = new Vector3(axisTransform.localEulerAngles.x, axisTransform.localEulerAngles.y, num); break; } }
private Vector3 GetInfluencedAxis(AxisInfluenced axisInfluenced) { Vector3 result = Vector3.zero; switch (axisInfluenced) { case AxisInfluenced.X: result = Vector3.right; break; case AxisInfluenced.Y: result = Vector3.up; break; case AxisInfluenced.Z: result = Vector3.forward; break; case AxisInfluenced.XYZ: result = Vector3.one; break; } return(result); }
void DoAngleLimitation(Transform axisTransform, AxisInfluenced axisInfluenced,float clampMin, float clampMax,float startAngle) { float angle=0; switch(axisInfluenced){ case AxisInfluenced.X: angle = axisTransform.localRotation.eulerAngles.x; break; case AxisInfluenced.Y: angle = axisTransform.localRotation.eulerAngles.y; break; case AxisInfluenced.Z: angle = axisTransform.localRotation.eulerAngles.z; break; } if (angle<=360 && angle>=180){ angle = angle -360; } //angle = Mathf.Clamp (angle, startAngle-clampMax, clampMin+startAngle); angle = Mathf.Clamp (angle, -clampMax, clampMin); switch(axisInfluenced){ case AxisInfluenced.X: axisTransform.localEulerAngles = new Vector3( angle,axisTransform.localEulerAngles.y, axisTransform.localEulerAngles.z); break; case AxisInfluenced.Y: axisTransform.localEulerAngles = new Vector3( axisTransform.localEulerAngles.x,angle, axisTransform.localEulerAngles.z); break; case AxisInfluenced.Z: axisTransform.localEulerAngles = new Vector3( axisTransform.localEulerAngles.x,axisTransform.localEulerAngles.y,angle); break; } }
float GetStartAutoStabAngle(Transform axisTransform, AxisInfluenced axisInfluenced) { float angle=0; if (axisTransform!=null){ switch(axisInfluenced){ case AxisInfluenced.X: angle = axisTransform.localRotation.eulerAngles.x; break; case AxisInfluenced.Y: angle = axisTransform.localRotation.eulerAngles.y; break; case AxisInfluenced.Z: angle = axisTransform.localRotation.eulerAngles.z; break; } if (angle<=360 && angle>=180){ angle = angle -360; } } return angle; }
Vector3 GetInfluencedAxis(AxisInfluenced axisInfluenced) { Vector3 axis = Vector3.zero; switch(axisInfluenced){ case AxisInfluenced.X: axis = Vector3.right; break; case AxisInfluenced.Y: axis = Vector3.up; break; case AxisInfluenced.Z: axis = Vector3.forward; break; case AxisInfluenced.XYZ: axis = Vector3.one; break; } return axis; }
void DoAutoStabilisation(Transform axisTransform, AxisInfluenced axisInfluenced, float threshold, float speed,float startAngle) { float angle=0; switch(axisInfluenced){ case AxisInfluenced.X: angle = axisTransform.localRotation.eulerAngles.x; break; case AxisInfluenced.Y: angle = axisTransform.localRotation.eulerAngles.y; break; case AxisInfluenced.Z: angle = axisTransform.localRotation.eulerAngles.z; break; } if (angle<=360 && angle>=180){ angle = angle -360; } if (angle > startAngle - threshold || angle < startAngle + threshold){ float axis=0; Vector3 stabAngle = Vector3.zero; if (angle > startAngle - threshold){ axis = angle + speed/100f*Mathf.Abs (angle-startAngle) * Time.deltaTime*-1; } if (angle < startAngle + threshold){ axis = angle + speed/100f*Mathf.Abs (angle-startAngle) * Time.deltaTime; } switch(axisInfluenced){ case AxisInfluenced.X: stabAngle = new Vector3(axis,axisTransform.localRotation.eulerAngles.y,axisTransform.localRotation.eulerAngles.z); break; case AxisInfluenced.Y: stabAngle = new Vector3(axisTransform.localRotation.eulerAngles.x,axis,axisTransform.localRotation.eulerAngles.z); break; case AxisInfluenced.Z: stabAngle = new Vector3(axisTransform.localRotation.eulerAngles.x,axisTransform.localRotation.eulerAngles.y,axis); break; } axisTransform.localRotation = Quaternion.Euler( stabAngle); } }
private float GetStartAutoStabAngle(Transform axisTransform, AxisInfluenced axisInfluenced) { float x = 0f; if (axisTransform != null) { switch (axisInfluenced) { case AxisInfluenced.X: x = axisTransform.localRotation.eulerAngles.x; break; case AxisInfluenced.Y: x = axisTransform.localRotation.eulerAngles.y; break; case AxisInfluenced.Z: x = axisTransform.localRotation.eulerAngles.z; break; } if ((x <= 360f) && (x >= 180f)) { x -= 360f; } } return x; }
private Vector3 GetInfluencedAxis(AxisInfluenced axisInfluenced) { Vector3 zero = Vector3.zero; switch (axisInfluenced) { case AxisInfluenced.X: return Vector3.right; case AxisInfluenced.Y: return Vector3.up; case AxisInfluenced.Z: return Vector3.forward; case AxisInfluenced.XYZ: return Vector3.one; } return zero; }
private void DoAutoStabilisation(Transform axisTransform, AxisInfluenced axisInfluenced, float threshold, float speed, float startAngle) { float x = 0f; switch (axisInfluenced) { case AxisInfluenced.X: x = axisTransform.localRotation.eulerAngles.x; break; case AxisInfluenced.Y: x = axisTransform.localRotation.eulerAngles.y; break; case AxisInfluenced.Z: x = axisTransform.localRotation.eulerAngles.z; break; } if ((x <= 360f) && (x >= 180f)) { x -= 360f; } if ((x > (startAngle - threshold)) || (x < (startAngle + threshold))) { float num2 = 0f; Vector3 zero = Vector3.zero; if (x > (startAngle - threshold)) { num2 = x + ((((speed / 100f) * Mathf.Abs((float) (x - startAngle))) * Time.deltaTime) * -1f); } if (x < (startAngle + threshold)) { num2 = x + (((speed / 100f) * Mathf.Abs((float) (x - startAngle))) * Time.deltaTime); } switch (axisInfluenced) { case AxisInfluenced.X: zero = new Vector3(num2, axisTransform.localRotation.eulerAngles.y, axisTransform.localRotation.eulerAngles.z); break; case AxisInfluenced.Y: zero = new Vector3(axisTransform.localRotation.eulerAngles.x, num2, axisTransform.localRotation.eulerAngles.z); break; case AxisInfluenced.Z: zero = new Vector3(axisTransform.localRotation.eulerAngles.x, axisTransform.localRotation.eulerAngles.y, num2); break; } axisTransform.localRotation = Quaternion.Euler(zero); } }
private void DoAngleLimitation(Transform axisTransform, AxisInfluenced axisInfluenced, float clampMin, float clampMax, float startAngle) { float x = 0f; switch (axisInfluenced) { case AxisInfluenced.X: x = axisTransform.localRotation.eulerAngles.x; break; case AxisInfluenced.Y: x = axisTransform.localRotation.eulerAngles.y; break; case AxisInfluenced.Z: x = axisTransform.localRotation.eulerAngles.z; break; } if ((x <= 360f) && (x >= 180f)) { x -= 360f; } x = Mathf.Clamp(x, -clampMax, clampMin); switch (axisInfluenced) { case AxisInfluenced.X: axisTransform.localEulerAngles = new Vector3(x, axisTransform.localEulerAngles.y, axisTransform.localEulerAngles.z); break; case AxisInfluenced.Y: axisTransform.localEulerAngles = new Vector3(axisTransform.localEulerAngles.x, x, axisTransform.localEulerAngles.z); break; case AxisInfluenced.Z: axisTransform.localEulerAngles = new Vector3(axisTransform.localEulerAngles.x, axisTransform.localEulerAngles.y, x); break; } }