示例#1
0
	void Awake ()
	{
		if (BtWorld.main == null || gameObject.tag.Equals ("main"))
			BtWorld.main = this;
		
		// TODO: expose in editor?
		broadphase = new BulletSharp.DbvtBroadphase ();
		collisionConfiguration = new BulletSharp.DefaultCollisionConfiguration ();
		dispatcher = new BulletSharp.CollisionDispatcher (collisionConfiguration);
		solver = new BulletSharp.SequentialImpulseConstraintSolver ();
		world = new BulletSharp.DiscreteDynamicsWorld (dispatcher, broadphase, solver, collisionConfiguration);
		
		world.Gravity = new BulletSharp.Vector3 (gravity.x, gravity.y, gravity.z);
		world.DebugDrawer = new UnityDebugDrawer ();
		world.DebugDrawer.DebugMode = BulletSharp.DebugDrawModes.None;
		foreach (BulletSharp.DebugDrawModes drawMode in debugDrawModes) {
			world.DebugDrawer.DebugMode |= drawMode;
		}
	}
示例#2
0
	void Start ()
	{
		myTransform = transform;
		if (shape == null)
			shape = GetComponent<BtShape> ();
		shape.AddObserver (changedShape);
		myRigidBody = createRigidBody (shape.Shape, myTransform, mass);
		
		if (isTrigger)
			myRigidBody.CollisionFlags |= BulletSharp.CollisionFlags.NoContactResponse;
		
		if (isKinematic)
			myRigidBody.CollisionFlags |= BulletSharp.CollisionFlags.KinematicObject;
		else if (Mathf.Approximately (mass, 0f))
			myRigidBody.CollisionFlags |= BulletSharp.CollisionFlags.StaticObject;
		
		if (world == null)
			world = BtWorld.main;
		world.World.AddRigidBody (myRigidBody);
	}