Ask here your questions to get help using GDevelop.
User avatar
By Jeje2201
#65831 Yes you can,
You just need to set the conditions you want,
For exemple you want your object to have physic when mouse over the object and other object that are not over disable the gravity, so you do a condition.
"if mouse over the object, make the object dynamic"
And you can make the object static, if it's not over by your mouse
"if mouse not over the object, make the object static"
Here is the action: http://prntscr.com/j3e30g
And so only object that are over and have gravity behavior would have gravity
By guepard
#65842
Jeje2201 wrote:Yes you can,
You just need to set the conditions you want,
For exemple you want your object to have physic when mouse over the object and other object that are not over disable the gravity, so you do a condition.
"if mouse over the object, make the object dynamic"
And you can make the object static, if it's not over by your mouse
"if mouse not over the object, make the object static"
Here is the action: http://prntscr.com/j3e30g
And so only object that are over and have gravity behavior would have gravity


Taht's not disable gravity. Static objects can't move.
User avatar
By Lizard-13
#65848 In HTML5 you can use a single line of code to disable the gravity for a specific instance:
At the beginning of the scene (or when you want to disable the gravity) add a JS sub-event, edit the JS event to pass your object as a list parameter and paste the following code:
Code: Select allobjects[0].getBehavior("Physics")._box2DBody.SetGravityScale(0);

Two things to note: It assumes the behavior is named "Physics", you can check this in the object properties panel. Also it assumes there is at least one instance of the object in the scene, otherwise your game will crash, if there is a chance to not have instances in the scene add a check before (I recommend to use it anyway):
Code: Select allif(objects.length > 0){
    objects[0].getBehavior("Physics")._box2DBody.SetGravityScale(0);
}


It was my result:
Floating.gif
Floating.gif (350.87 KiB) Viewed 618 times


Impossible to do in native right now :(