Physics Help with Flipping Gravity

help_me_please

#1

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


#2

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


#3

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

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


#5

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.


#6

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


#7

Did it help @MISSION_IMPOSSIBLE?


#8

Yeah, that was helpful but I don’t think it should bounce.


#9

@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.


#10

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


#11

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.


#12

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.