Tutorial on Physics Simulation

I’d like to incorporate physics simulation into my game. It seems that physics simulation is available in AccelG, but I’m not quite sure how to use it…

Would it be possible to provide a tutorial?

If there is already an explanation page, please let me know.

From what I’ve found there isn’t an official physics tutorial yet. The PhysicsGameObject node in the Add Node list isn’t finished, its description in the editor says not implemented, and nothing in Visual Script uses it, so I’d leave that one for now. Regular Godot physics does work in AGMaker though, and the quickest way to try it is a box the player can push around.

  1. Create a new scene with a RigidBody2D as the root, add a CollisionShape2D and a Sprite2D under it, and save it.
  2. On the RigidBody2D, set Mass, then under Physics Material Override add a new PhysicsMaterial and set Friction and Bounce.
  3. Set its Collision Layer and Mask to match the player’s wall collision, or they’ll go through each other.
  4. Place the scene in your map and play. It should fall, land and sit there.
  5. Download CA_PushRigidBody.gd from the official samples post and put it anywhere in your project folder: カスタムアクションプラグイン公式サンプル
  6. On the player, add the Push RigidBody action to the walking state. While that state runs, any RigidBody2D the player walks into gets pushed, and Push Force sets how hard.

Moonling wrote up the different body types and what each one is for, which helps when deciding what a given object should be:

The limit is that a Visual Script only runs on an object whose root is a GameObject, so the box above can’t have its own script. If you want a physics object that reacts in Visual Script, like rubble that damages the player, Moonling posted a GameObject with a RigidBody2D child and a small script that keeps the two together. It’s marked as a proof of concept, so I’d test it a bit before building on it:

If what you’re after is more like conveyor belts, jump pads or wind, I think the Force Area and Set Object Velocity added in 2.0 might get you there without any of the above:

1 Like