private void SetUpPhysicsOnWheels(Physic3DCollisionGroup wheelCollisionGroup) { var wheels = this.EntityManager.FindAllByTag("wheel").Cast <Entity>(); if (wheels == null || wheels.Count() == 0) { return; } var chasis = this.EntityManager.Find("chasis"); if (chasis == null) { return; } var i = 0; foreach (var wheel in wheels) { var wheelRigidBody = wheel.FindComponent <RigidBody3D>(); if (wheelRigidBody == null) { return; } wheelRigidBody.CollisionGroup = wheelCollisionGroup; var hingeJoint = new HingeJoint3D(chasis, Vector3.Zero, -Vector3.UnitY); var jointMap = new JointMap3D() .AddJoint("chasisWheelJoint" + i++, hingeJoint); if (wheel.Name.Contains("Front")) { hingeJoint.IsMotorEnabled = true; hingeJoint.MotorVelocity = MathHelper.Pi * 2; hingeJoint.MotorDamping = 1 / 500; hingeJoint.MotorMaxForce = 500; } wheel.AddComponent(jointMap); } }
public override void OnSyncedStart() { thisBody = GetComponent <TSRigidBody> (); IBody3D body1 = GetComponent <TSCollider> ().Body; IBody3D body2 = connectedBody.Body; Vector3 worldPos = transform.TransformPoint(anchor); TSVector TSworldPos = worldPos.ToTSVector(); Vector3 worldAxis = transform.TransformDirection(Axis); TSWorldAxis = worldAxis.ToTSVector(); Debug.Log("Hinge joint"); //if (useLimits) // thisJoint = new LimitedHingeJoint(PhysicsWorldManager.instance.GetWorld(), body1, body2, TSworldPos, TSWorldAxis, -Limits.Min, Limits.Max); //else thisJoint = new HingeJoint3D(PhysicsWorldManager.instance.GetWorld(), body1, body2, TSworldPos, TSWorldAxis); //charac joint = new CharacterJoint (); }
private void SetUpPhysicsOnWheels(Physic3DCollisionGroup wheelCollisionGroup) { var wheels = this.EntityManager.FindAllByTag("wheel").Cast<Entity>(); if (wheels == null || wheels.Count() == 0) { return; } var chasis = this.EntityManager.Find("chasis"); if (chasis == null) { return; } var i = 0; foreach (var wheel in wheels) { var wheelRigidBody = wheel.FindComponent<RigidBody3D>(); if (wheelRigidBody == null) { return; } wheelRigidBody.CollisionGroup = wheelCollisionGroup; var hingeJoint = new HingeJoint3D(chasis, Vector3.Zero, -Vector3.UnitY); var jointMap = new JointMap3D() .AddJoint("chasisWheelJoint" + i++, hingeJoint); if (wheel.Name.Contains("Front")) { hingeJoint.IsMotorEnabled = true; hingeJoint.MotorVelocity = MathHelper.Pi * 2; hingeJoint.MotorDamping = 1 / 500; hingeJoint.MotorMaxForce = 500; } wheel.AddComponent(jointMap); } }