# Physics Help with Flipping Gravity

I am making a game where when you tap the screen, the gravity flips. There will be massive saws coming at you and you need to dodge them. I need help with making the floors actually function as a floor. You need to stop, no matter what, when you hit them, but still be able to go up once the gravity flips. @CodeHelp WIP: https://c.gethopscotch.com/p/zye9z5okh

9 Likes

@CreationsOfaNoob, @ThinBuffalo and @Petrichor knows this kind of stuff (correct me if Iâ€™m wrong).

2 Likes

Ooh fun.
I think fearless might be able to help, Iâ€™ll get them to check out your draft and see if they can do anything for ya.

4 Likes

@MISSION_IMPOSSIBLE
IDK if this will help but you should take a look

Edit: I misread your post originally, you need to stop completely when you hit the floors. Just set gravity to 0 when distance y between man and self is less than some number. Also, only do it gravity is pulling towards the object. You may need to use multiple rules for each clone index of floor.

3 Likes

Thatâ€™s what I applied in my code, also when you tap, a variable called antigravity changes

Did it help @MISSION_IMPOSSIBLE?

Yeah, that was helpful but I donâ€™t think it should bounce.

@Petrichor, that is what I did. However, if you were coming at the floor at any large velocity, you would sink through it. And, if you flipped just before you hit the floor, you could go through it completely because you were the other way around and therefore the rule wasnâ€™t triggering. That is the problem I donâ€™t know how to fix.

1 Like

Really sorry! I just realised that in my project, the man bounced. That was just me experimenting.

Here is the actual link: https://c.gethopscotch.com/p/zyoh1by9e

1 Like

Then if you use a clone index 1 rule and a clone index 2 rule, you can just check if man y position is less than self y position+ something for clone index 1, and the opposite for 2.

3 Likes

Sounds like a good game, but Iâ€™m not good with that kind of code.
I agree with @William04GamerA though, they do know a lot about that type of code.

1 Like