物理功能


The integration of a dedicated physics library to GameMaker Studio 2 means that you can now take control over all aspects of the physical behaviour of objects within your game world, particularly collisions and object interaction. The "traditional" collision system (which GameMaker Studio 2 defaults to) is a "reactive" system, where you check for a collision and then react to that collision with code that you place in individual objects. This is fine for simple games, but when you have a large number of objects and have to code how they all react to different situations in the game world, it quickly becomes obvious that this system is just not enough. That's when you have to turn to the GameMaker Studio 2 physics system.

The physics system works in a very different way to normal collisions. It is more of a "passive" system where you define a series of properties for your objects in the game world, as well as the properties of the game world itself, before any collisions or interactions occur. These coded "rules" will then govern the way everything in your game world interacts. In this way, with a few simple code and the correct room setup, you can create very complex interactions between objects and the world which will occur and resolve without you having to code for every single possible outcome.

There are a few things that you should note when working with the GameMaker Studio 2 physics world:

Information on the physics functions can be found on the following pages:

  1. 物理世界
  2. 作用力
  3. 支架
  4. 关节
  5. 柔体粒子
  6. 物理变量

Finally, there are a couple of special physics functions which may be useful for more advanced physics simulations. The first is for testing for possible collisions at a specific point in the room, and the second is for generating custom mass and inertia properties within an instance: