/// <summary> /// Drive rocker by velocity. /// </summary> /// <param name="velocity">Velocity of drive.</param> /// <param name="type">Type of drive.</param> public override void Drive(float velocity = 0, DriveType type = DriveType.Ignore) { joint.position = transform.position; var angle = -EVector3.ProjectAngle(joint.forward, ZeroAxis, Axis); var euler = new Vector3(transform.localEulerAngles.x, transform.localEulerAngles.y, angle); transform.localRotation = Quaternion.Euler(euler); }
/// <summary> /// Drive rocker. /// </summary> public override void Drive() { rockJoint.position = transform.position; var angle = -EVector3.ProjectAngle(rockJoint.forward, ZeroAxis, Axis); var euler = new Vector3(transform.localEulerAngles.x, transform.localEulerAngles.y, angle); transform.localRotation = Quaternion.Euler(euler); }
private void OnTrigger(ESphereCollider other) { if (other != null) { Vector3 direction = EVector3.Normalize((other.Center - transform.position)); other.MyRigidbody.AddForce(direction, _force); } else { Debug.LogError("Trigger \"other\": NULL"); } }
public static float SqrMagnitude (EVector3 a) { return a.x * a.x + a.y * a.y + a.z * a.z; }