/// <summary> /// Adds a wheel to the BRaycastVehicle from the given information. /// </summary> /// <param name="connectionPoint"></param> /// <param name="axle"></param> /// <param name="suspensionRestLength"></param> /// <param name="radius"></param> /// <returns></returns> public int AddWheel(WheelType wheelType, BulletSharp.Math.Vector3 connectionPoint, BulletSharp.Math.Vector3 axle, float suspensionRestLength, float radius) { float slidingFriction = DefaultSlidingFriction; switch (wheelType) { case WheelType.MECANUM: slidingFriction = 0.1f; axle = (Quaternion.AngleAxis((connectionPoint.X > 0 && connectionPoint.Z > 0) || (connectionPoint.X < 0 && connectionPoint.Z < 0) ? -45 : 45, Vector3.up) * axle.ToUnity()).ToBullet(); break; case WheelType.OMNI: slidingFriction = 0.1f; break; } RobotWheelInfo wheel = RaycastRobot.AddWheel(connectionPoint, -BulletSharp.Math.Vector3.UnitY, axle, suspensionRestLength, radius, defaultVehicleTuning, false); wheel.RollInfluence = RollInfluence; wheel.SlidingFriction = slidingFriction; return(RaycastRobot.NumWheels - 1); }
/// <summary> /// Adds a wheel to the BRaycastVehicle from the given information. /// </summary> /// <param name="connectionPoint"></param> /// <param name="axle"></param> /// <param name="suspensionRestLength"></param> /// <param name="radius"></param> /// <returns></returns> public int AddWheel(WheelType wheelType, BulletSharp.Math.Vector3 connectionPoint, BulletSharp.Math.Vector3 axle, float suspensionRestLength, float radius) { switch (wheelType) { case WheelType.MECANUM: RaycastRobot.SlidingFriction = 0.1f; axle = (Quaternion.AngleAxis((connectionPoint.X > 0 && connectionPoint.Z > 0) || (connectionPoint.X < 0 && connectionPoint.Z < 0) ? -45 : 45, Vector3.up) * axle.ToUnity()).ToBullet(); break; case WheelType.OMNI: RaycastRobot.SlidingFriction = 0.1f; break; } WheelInfo w = RaycastRobot.AddWheel(connectionPoint, -BulletSharp.Math.Vector3.UnitY, axle, suspensionRestLength, radius, vehicleTuning, false); w.RollInfluence = 0.25f; w.Brake = (RollingFriction / radius) * RaycastRobot.OverrideMass * BRaycastWheel.MassTorqueScalar; return(RaycastRobot.NumWheels - 1); }