Example #1
0
 /// <summary>
 /// Deregisters a raycast robot with the BRobotManager.
 /// </summary>
 /// <param name="raycastRobot"></param>
 public void DeregisterRaycastRobot(RaycastRobot raycastRobot)
 {
     if (raycastRobots.Contains(raycastRobot))
     {
         raycastRobots.Remove(raycastRobot);
     }
 }
Example #2
0
 /// <summary>
 /// Registers a raycast robot with the BRobotManager.
 /// </summary>
 /// <param name="raycastRobot"></param>
 public void RegisterRaycastRobot(RaycastRobot raycastRobot)
 {
     if (!raycastRobots.Contains(raycastRobot))
     {
         raycastRobots.Add(raycastRobot);
     }
 }
Example #3
0
 /// <summary>
 /// Updates each wheel's position for proper interpolation.
 /// </summary>
 private void Update()
 {
     for (int i = 0; i < RaycastRobot.NumWheels; i++)
     {
         RaycastRobot.UpdateWheelTransform(i, true);
     }
 }
Example #4
0
        /// <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,
                                                         rootNode.WheelsNormal.ToBullet(), axle, suspensionRestLength,
                                                         radius, defaultVehicleTuning, false);

            wheel.RollInfluence   = RollInfluence;
            wheel.SlidingFriction = slidingFriction;

            return(RaycastRobot.NumWheels - 1);
        }
Example #5
0
        /// <summary>
        /// Initializes the BRaycastVehicle.
        /// </summary>
        private void Awake()
        {
            rigidBody = GetComponent <BRigidBody>();

            if (rigidBody == null)
            {
                Destroy(this);
                return;
            }

            RaycastRobot = new RaycastRobot(defaultVehicleTuning = new VehicleTuning
            {
                MaxSuspensionForce    = 1000f,
                MaxSuspensionTravelCm = SuspensionToleranceCm,
                SuspensionDamping     = 10f,
                SuspensionCompression = SuspensionCompressionRatio,
                SuspensionStiffness   = CalculateStiffness(DefaultNumWheels),
                FrictionSlip          = 2f
            },
                                            (RigidBody)rigidBody.GetCollisionObject(),
                                            new BRobotRaycaster((DynamicsWorld)BPhysicsWorld.Get().world));

            BRobotManager.Instance.RegisterRaycastRobot(RaycastRobot);
        }