Disable gravity in some physic objects

Disable gravity in some physic objects

There is any way to have gravity in some objects and disable it in others? I'm talking about physic behaviour.

Re: Disable gravity in some physic objects

Posted: Tue 10 Apr 2018, 16:20

by Jeje2201

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/j3e30gAnd so only object that are over and have gravity behavior would have gravity

Re: Disable gravity in some physic objects

Posted: Thu 12 Apr 2018, 09:52

by guepard

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/j3e30gAnd so only object that are over and have gravity behavior would have gravity

Taht's not disable gravity. Static objects can't move.

Re: Disable gravity in some physic objects

Posted: Thu 12 Apr 2018, 14:58

by Lizard-13

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:

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):