Esempio n. 1
0
        public Vector3 CalculateFriction(Vector3 velocity, Vector3 force, float normal, float mass)
        {
            var time         = Time.fixedDeltaTime;
            var acceleration = new Vector3();

            fe = ue * -Vector3.Normalize(velocity) * normal;
            fc = uc * -Vector3.Normalize(velocity) * normal;

            if (Vector3.Magnitude(velocity) > 0f)
            {
                acceleration = (force + fc / mass);
            }
            else
            {
                acceleration = (force + fe / mass);
            }

            if (((Vector3.Magnitude(force) - Vector3.Magnitude(fe)) > 0f) || (Vector3.Magnitude(velocity) > 0f))
            {
                velocity += acceleration * time;
            }
            else
            {
                velocity = Vector3.Zero;
            }

            return(velocity);
        }
 public static UnityEngine.Vector3 ToUnity(this Vector3 value) => new UnityEngine.Vector3(value.X, value.Y, value.Z);