How to make an object defy gravity temporarily?

Hello! I'm making a game where you shoot magnetic charges from a gun. You have to shoot boxes to make them move. Since I have bullets I'm not using gravity but accelerating down. I'm having problems with the boxes. I need them to have gravity when accelerating down either in the beginning of the scene or when they lose their magnetic charge, but not when they move because to make them move I'm using an accelerate towards behavior (only way to get it to move towards a magnet point). This doesnt work however because with gravity it will accelerate differently horizontally and vertically! I've tried a bunch of different ways to temporarily disable gravity but none of them work! Any ideas?
Best Answer
-
gyroscope I am here.Posts: 6,598
Hi @pxlpfct
You're correct that the gravity attribute itself can't be switched on or off during gameplay, so using accelerate is a good workaround. Firstly, make sure that you've 0 and 0 in the X and Y of the Gravity attribute in your scene (Scene > Attributes > Gravity).
What's then needed is the good ol' boolean switch. You'll need one for each of your boxes. So something like when your bullet hits one of the boxes,
When bullet overlaps or collides with Box1
Change Attribute Switch1 to true
When bullet overlaps or collides with Box2
Change Attribute Switch2 to true
--------etc.
And then in each of your box Rules:
When Switch(---number) is true)
Accellerate Relative to Scene
----set to 270 for downwards, if I've understood correctly.
That sort of thing; with experimentation based on what I've written, it should work out for you, hopefully.
----------------------------------------------
http://davidgriffinapps.co.uk/
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
Answers