public override void XStart() { nonMonoPhysics = new List <NonMonoBehaviorPhysics> (); dynamicColliders = new List <PhysicsBehaviourX>(); staticColliders = new List <PhysicsBehaviourX>(); _physicsSpace = new BEPUphysics.Space(); _physicsSpace.ForceUpdater.Gravity = Gravity.ToBEPU(); _physicsSpace.BufferedStates.Enabled = BufferedStates; _physicsSpace.Solver.IterationLimit = IterationLimit; //Don't need many iterations, there's not really any stacking going on in this game. _physicsSpace.TimeStepSettings.TimeStepDuration = TimeStep; //A slower timestep gives the Xbox a little breathing }
// Use this for initialization public override void XStart() { if (!isInit) { meshfilter = transform.GetComponent <MeshFilter>(); Collider = transform.GetComponent <MeshCollider>(); position = Collider.bounds.center; rotation = meshfilter.transform.rotation; scale = meshfilter.transform.localScale; mesh = meshfilter.sharedMesh; if (transform.GetComponent <Rigidbody>() != null) { rigid = transform.GetComponent <Rigidbody>(); mass = rigid.mass; } List <BEPUutilities.Vector3> vertices = new List <BEPUutilities.Vector3>(); int[] indices = new int[mesh.GetIndexCount(0)]; indices = mesh.GetIndices(0); for (int i = 0; i < mesh.vertices.Length; i++) { vertices.Add(mesh.vertices[i].ToBEPU()); } entity = new BEPUphysics.BroadPhaseEntries.StaticMesh(vertices.ToArray(), indices, new AffineTransform(scale.ToBEPU(), rotation.ToBEPU(), position.ToBEPU())); entity.Sidedness = TriangleSidedness.DoubleSided; PhysicsManagerBehavior.Space.Add(entity); this.enabled = false; isInit = true; } }