Physics Help for a Game



I can’t do ‘When touching (air)’. I wish there was a ‘When not touching’.


Are you gonna use my code?


The blocks themselves need to do the collision testing since they have access to their own attributes.

Block_size = e.g 40 

When abs(player.y - self.y) < block_size:
  player.yvelocity = player.yvelocity * -0.8

When abs(player.y - self.y) < block_size:
  If player.y > self.y:
    Set player.y to self.y + block_size
    Set player.y to self.y - block_size

...and the same for x.

This method uses no bump blocks.


Thanks! Just wondering though, what code would I put into the ‘Player’ object to make it adhere to what the terrain was telling it to do?


Make a variable: when [(self)is on ground] set [(self)vertical velocity] to 0
And make a variable called Y, which is the Y position of the character, and increase that variable by your vertical velocity, when you make that, make the collisions COAN already said but add the Ypos variable, when [PlayerY-selfY]<40
Set [(player)is on ground] to 1
Check once if playerY<SelfY+33
Increase playerY by 1


Just some basic physics:
Each of these should be in a separate 7=7/repeat forever
Increase player.y by player.yvelocity
Increase player.x by player.xvelocity
Increase player.yvelocity by -1 (gravity)


Thanks! I’ll try and implement it!


I’m fairly sure I did it right but it is really not working…
Could you please check if I have done anything wrong?


/ is divide, * is multiply


You’ll just need to check if the block is invisible.
Like ”when (y thing) and invisibility=0”


Oh. Yeah. Thanks… Duh. :no_mouth:


Sorry, forgot another thing. You’ll also need to check if the player is close on the x plane.
So like this: when abs(ypos-self.ypos) < 25 and abs(xpos-self.xpos) < 25 and invisibility=0

@MISSION_IMPOSSIBLE look at this post


Hang on… I always land on air at the highest point of the terrain, just floating.


I really appreciate all your help, but it still isn’t quite working.


That’s because you haven’t added the x part. Just copy the physics code for y (you can hold down on the custom rule and copy it) and change it to x.


I did though.


Yeah, for the y collision detection.
But I was meaning a whole new custom ability with the same code as the current but with all the set y and set yvelocity changed to set x and set xvelocity.


Okay, maybe I am being stupid but I cannot for the life of me get this thing to work. I did exactly what you said. Could you please make a copy of one of my projects and put in the physics and then I can try and implement it into my own version and see where I went wrong?


Ok. There might be an easy fix: I got it to work by changing the collision detection variable a bit (I believe it’s 25). For the x bouncing I increased the x detection by 1 and the y detection by -5.
For the y bouncing I increased the x detection by -5 and the y detection by 1.
This might work


What’s wrong here?