You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You can use the "**Separate objects**" action to move objects manually. The "Separate objects" action can also move objects with "forces" or set the object's position.
14
-
15
-
"**Separate objects.**" This action takes two object names as the argument.
13
+
"**Separate objects**" is an action that keeps two types of objects from overlapping. It takes two object names as the argument.
16
14
17
15
* The first object name is the _object moving_ (the player, enemy, etc.).
18
16
* The second object name is an _object (or a group of objects) that are solid_. For example, these objects can be the walls.
@@ -25,7 +23,7 @@ This action will be launched in every frame. In an event without conditions, the
25
23
26
24
### Detect collisions
27
25
28
-
Using "Separate objects" is a good way to ensure that your objects can't move into other solid objects. This action checks collisions between objects. For example, if the game object "player" is touching a wall, this action, when used with the condition called "**Collision,**" will trigger damages to the player.
26
+
Using "Separate objects" is a good way to ensure that your objects can't move into other solid objects. You can pair it with the "**Collision**" condition to both detect a collision and react to it — for example, dealing damage to the player when touching an enemy, then separating them.
29
27
30
28
**The sequence is important.**
31
29
@@ -63,21 +61,21 @@ In a platformer game with the "Platformer character" behavior, collisions with p
63
61
**See it in action!** 🎮
64
62
Open this example online: [Platformer Example](https://editor.gdevelop.io?project=example://platformer)
65
63
66
-
## Game with physics? Use the Physics behavior
64
+
## Game with physics? Use the Physics 2 behavior
67
65
68
-
Use [Physics behavior](/gdevelop5/behaviors/physics) in order to achieve realistic physical behavior in your game. Attach "Physics" behavior to your objects. The objects will then behave as though they are alive in the game world. Some examples of real-world behavior include bouncing balls, falling, jumping, etc.
66
+
Use the [Physics 2 behavior](/gdevelop5/behaviors/physics2)to make objects move realistically, simulating gravity, bouncing, and other real-world physical interactions. This is well suited for games like pinball, angry-birds-style projectile games, or anything that relies on natural-feeling collisions and movement.
69
67
70
-
Configure game walls or solid objects that should not move with "static" behavior.
68
+
Objects configured as **Static** will not move and act as immovable walls or ground. Objects configured as **Dynamic** are fully simulated and react to gravity, forces, and collisions.
71
69
72
-
### Detect collisions with the Physics behavior
70
+
### Detect collisions with the Physics 2 behavior
73
71
74
-
When you're using the **Physics** behavior, _do not use_ the **Collision** condition that is in the **Features for all objects** category. _The physics engine will manage all collisions by itself._The Collision condition won't correctly detect when objects are touching.
72
+
When you're using the **Physics 2** behavior, _do not use_ the **Collision** condition that is in the **Features for all objects** category. _The physics engine will manage all collisions by itself._ The standard Collision condition won't correctly detect when objects are touching.
75
73
76
-
Instead, use the Collision condition _inside the_**Physics**_behavior category_, which properly uses the physics engine to simulate the collisions.
74
+
Instead, use the Collision condition _inside the_**Physics 2**_behavior category_, which properly uses the physics engine to simulate the collisions.
Additionally, objects with the **Physics** behavior ignore the object's Collision Masks and instead use the collision information on the **BEHAVIORS** tab of the object itself. This defaults to a box that is the full dimension of the object. In most cases, there will be a need to change these settings from within the **BEHAVIORS** tab.
78
+
Additionally, objects with the **Physics 2** behavior ignore the object's Collision Masks and instead use the collision shape configured on the **BEHAVIORS** tab of the object itself. This defaults to a box matching the full dimensions of the object. The shape can be changed to a circle, edge, or polygon from within the **BEHAVIORS** tab.
Copy file name to clipboardExpand all lines: docs/gdevelop5/behaviors/events-based-behaviors/index.md
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -57,17 +57,17 @@ Events from the **onCreated** function are run when a new instance of an object
57
57
58
58
### Run events every frame
59
59
60
-
Events from the **onStepPreEvents** function are run every time a frame is rendering on the screen before the "traditional" events of the scene. Typically this is done 60 times per second. It's called for every single object having the behavior unless it's deactivated.
60
+
Events from the **doStepPreEvents** function are run every time a frame is rendering on the screen before the "traditional" events of the scene. Typically this is done 60 times per second. It's called for every single object having the behavior unless it's deactivated.
61
61
62
-
The following `onStepPreEvents` function events automatically deletes objects that are too damaged:
62
+
The following `doStepPreEvents` function events automatically deletes objects that are too damaged:
63
63
64
64

65
65
66
66
### Add custom action, condition or expression
67
67
68
68
Behaviors and the scene events communicate through functions:
69
69
70
-
- Actions allow to change the state of the behavior and maybe initiate an effect over time in the `onStepPreEvents` function. For instance, a jump action changes the character state from standing to jumping and `onStepPreEvents` modify the character position on Y axis every frame.
70
+
- Actions allow to change the state of the behavior and maybe initiate an effect over time in the `doStepPreEvents` function. For instance, a jump action changes the character state from standing to jumping and `doStepPreEvents` modify the character position on Y axis every frame.
71
71
- Conditions let scene events know about behavior state changes. For instance, a condition can allow to check if a character is jumping.
72
72
73
73
!!! tip
@@ -80,12 +80,12 @@ For example, this function defines an action that can be used to add damage to t
80
80
81
81
### Run events at other lifecycle key times
82
82
83
-
Even though, the lifecycle functions **onCreated** and **onStepPreEvents** are the most common, the following function can also be used:
83
+
Even though, the lifecycle functions **onCreated** and **doStepPreEvents** are the most common, the following function can also be used:
84
84
85
85
***onDestroy**: events that will be run when an instance of the object having the behavior is deleted (if multiple objects are removed at the same time, events will be run for each object). This is done even if the behavior is deactivated.
86
86
***onDeActivate**: events that will be run once, after the behavior is deactivated on an object.
87
87
***onActivate**: events that will be run once, after the behavior is activated again on an object.
88
-
***onStepPostEvents**: events that will be run for every single object having the behavior, after the "traditional" events of the scene, if the behavior is not deactivated. Typically, this is done 60 times per second. It's recommend to prefer `onStepPreEvents`, to run your logic before events and give the events in the scene a chance to react to changes that happen on the objects.
88
+
***doStepPostEvents**: events that will be run for every single object having the behavior, after the "traditional" events of the scene, if the behavior is not deactivated. Typically, this is done 60 times per second. It's recommended to prefer `doStepPreEvents`, to run your logic before events and give the events in the scene a chance to react to changes that happen on the objects.
89
89
90
90
## Use the behavior on an object
91
91
@@ -101,7 +101,7 @@ The custom behavior that you created is then displayed in the list of the behavi
101
101
102
102

103
103
104
-
You can run the game and see that the events in "doStepPreEvents" function (or "doStepPostEvents") will be executed. In the example of the Destructible behavior that was created, if the "Damage" variable is set to a number greater or equal to 100, the object will be destroyed automatically.
104
+
You can run the game and see that the events in the `doStepPreEvents` function (or `doStepPostEvents`) will be executed. In the example of the Destructible behavior that was created, if the "Damage" variable is set to a number greater or equal to 100, the object will be destroyed automatically.
105
105
106
106
To test this, we've added the "Destructible" behavior to object "Platform". Then, when using the debugger, we can inspect "Platform" instances and see that they have a "Damage" variable (set to 0). If we use the debugger (or an event) to set it to 100, the object is removed from the scene:
0 commit comments