Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
gdevelop5:behaviors:physics2 [2021/01/29 18:36]
yu-tang [Friction Joint] bulletize "Maximum torque"
gdevelop5:behaviors:physics2 [2021/05/11 16:50] (current)
victrisgames [Layers & Masks] Added "Collision" to title of sction
Line 6: Line 6:
 \\ \\
 <note important>Limitation: As stated above, the extension simulates rigid bodies physics, which means that bodies can't be deformed. Things like soft shapes, clothes, and fluids are not supported.</note> <note important>Limitation: As stated above, the extension simulates rigid bodies physics, which means that bodies can't be deformed. Things like soft shapes, clothes, and fluids are not supported.</note>
 +
 +{{ :gdevelop5:behaviors:physics2-behavior-properties.jpg?nolink&600 |}}
  
 ##World ##World
Line 69: Line 71:
 <note>You can use a negative gravity scale to invert the gravity for a specific object.</note> <note>You can use a negative gravity scale to invert the gravity for a specific object.</note>
  
-###Layers & Masks+###Collision Layers & Masks
  
-Layers and masks are the way to filter collisions between objects. Imagine you're building a zombie game, and you want your player to collide with the ground, and want the zombies to collide with the player and with the ground as well, but you don't want zombies to collide with other zombies, for such a case, you need collision filters.+Layers and masks are the way to filter collisions between objects.  
 + 
 +  * **Layer**:  Logical group that an object can belong to.  Objects can be a member of multiple layers. \\ 
 +  * **Mask**:  List of the layers that an object will collide with.  \\ 
 + 
 +<note>Physics collision layers are not related to layers that are used to place objects in a scene.   
 +</note> 
 + 
 +This system allows you to build up complex interactions between a variety of objects.  Imagine you're building a zombie game, and you want your player to collide with the ground, and want the zombies to collide with the player and with the ground as well, but you don't want zombies to collide with other zombies, for such a case, you need collision filters.
  
 How do filters work? How do filters work?
Line 81: Line 91:
   * Player: Enable the first layer and the first and second masks.   * Player: Enable the first layer and the first and second masks.
   * Zombie: Enable the second layer and the first mask only.   * Zombie: Enable the second layer and the first mask only.
 +
 +^ Object      ^ Layer       ^ Mask          ^
 +| Ground | 1 | 1, 2  |
 +| Player | 1 | 1 ,2 |
 +| Zombie | 2 | 1 |
 +
 Why does it work? Why does it work?
   * Ground & Player: A ground layer matches a player mask (first), **and** a player layer matches a ground mask (first)   * Ground & Player: A ground layer matches a player mask (first), **and** a player layer matches a ground mask (first)
Line 87: Line 103:
   * Zombie & Zombie: The zombie has only the second layer enabled, and only the first mask enabled, so zombies can't collide with each other.   * Zombie & Zombie: The zombie has only the second layer enabled, and only the first mask enabled, so zombies can't collide with each other.
  
-Note that you have 16 layers and 16 masks available, and to solve our little problem, only two layers and masks were needed.+Note that you have 16 layers and 16 masks available, and to solve our little problem, only two layers and masks were needed.  By default, all physics objects will use layer 1 and mask 1.
  
 ###Movement ###Movement
Line 96: Line 112:
  
   * **Forces**: Forces change an object's movement and are meant to be used for some time to generate an appreciable effect. The velocity the object gains, when you apply on it a force depends on the force's magnitude and the object mass. A heavy object will move slower than a lighter one if the same force is applied on both the masses.\\ \\   * **Forces**: Forces change an object's movement and are meant to be used for some time to generate an appreciable effect. The velocity the object gains, when you apply on it a force depends on the force's magnitude and the object mass. A heavy object will move slower than a lighter one if the same force is applied on both the masses.\\ \\
-__An application point must be se to add a force..__\\ \\+__An application point must be set to add a force..__\\ \\
   * **Torques**: Analogous of forces but for rotation. A torque will generate an angular acceleration on the object, making it rotate faster or slower along the time.   * **Torques**: Analogous of forces but for rotation. A torque will generate an angular acceleration on the object, making it rotate faster or slower along the time.
   * **Impulses**: Like forces, but not depending on the time step, instead, adding an "amount" of velocity instantly. They're meant to be used a single time. An everyday use could simulate jumps: each time the jump button is pressed, add an impulse upwards.\\ \\   * **Impulses**: Like forces, but not depending on the time step, instead, adding an "amount" of velocity instantly. They're meant to be used a single time. An everyday use could simulate jumps: each time the jump button is pressed, add an impulse upwards.\\ \\
Line 153: Line 169:
   * **Reference angle**: The angle between the objects that will be considered as zero. It offsets all the angle properties. If the reference angle is 15 degrees, asking for the current joint angle when the angle between the objects is 15 degrees in world coordinates will return 0, and set the maximum angle to 30 will set it to 45 (relative to the first object).   * **Reference angle**: The angle between the objects that will be considered as zero. It offsets all the angle properties. If the reference angle is 15 degrees, asking for the current joint angle when the angle between the objects is 15 degrees in world coordinates will return 0, and set the maximum angle to 30 will set it to 45 (relative to the first object).
   * **Minimum angle**: The minimum angle between the objects, relative to the first object. Must be lower than or equal to the maximum angle.   * **Minimum angle**: The minimum angle between the objects, relative to the first object. Must be lower than or equal to the maximum angle.
-  * **Maximum angle**: The minimum angle between the objects, relative to the first object. Must be greater than or equal to the minimum angle.+  * **Maximum angle**: The maximum angle between the objects, relative to the first object. Must be greater than or equal to the minimum angle.
 <note tip>You can use revolute joints with angle limits to simulate articulations, in other words, ragdolls!</note> <note tip>You can use revolute joints with angle limits to simulate articulations, in other words, ragdolls!</note>
   * **Motor**: If enabled, the joint will add torque to the second object to make it rotate without the need of an external force, like a motor. If you enable it, remember to set a motor speed and a maximum motor torque!   * **Motor**: If enabled, the joint will add torque to the second object to make it rotate without the need of an external force, like a motor. If you enable it, remember to set a motor speed and a maximum motor torque!