Sprite in continuous fall

I’m having a fantastic time learning new skills and relearning some old skills with Arcade.

I’ve run into a roadblock in my platformer upon using the “place Sprite on top of random tile” block.

Approximately half the time this works fine as expected. However, often when the sprite is transported to the new location, it continuously accelerates through all the walls downward into the abyss and I must do a reset.

Is this a known bug or am I possibly missing something?

Could you share your code?

I will share as soon as I figure out how. :blush:

If you open up your game, you can click “share” in the top bar to publish it. Here’s a gif of me doing that:

Paste the link in the last dialog here!

Thank you. I’ve been attempting that. When I try to publish and share I’m getting “bad http status code 413”. Is my code to large?

Huh, that might be the case! Well, if you can go into the JavaScript tab and copy-paste the code here that might work

It’s quite a bit of code with many levels and background images. I’ve got it set up to start at level 9 as that is where I am first noticing the problem. When on top of an “up arrow” tile, pressing the up button places the sprite on the “out” tile. This is the moment where sometimes it works, and other times the sprite just continues to accelerate down through walls.

Hope this attachment works.

(Attachment Bailey’s Fun.txt is missing)

It’s quite a bit of code with many levels and background images. I’ve got it set up to start at level 9 as that is where I am first noticing the problem. When on top of an “up arrow” tile, pressing the up button places the sprite on the “out” tile. This is the moment where sometimes it works, and other times the sprite just continues to accelerate down through walls.

Hope this attachment works.

arcade-Baileys-Fun (16).png

You can also export your game to GitHub using the GitHub button next to the save button.

Thanks for reporting this; that’s a great bug! Let me try to explain what’s going on here:

MakeCode has logic for when sprites “clip” into walls to prevent collisions from happening. We do that so if you move a sprite inside a wall by setting x/y directly, it won’t immediately bounce back out again. So, if a sprite is teleported inside of a wall it will cease to collide with walls until it exits the wall and collisions are turned back on.

The reason this is triggering in your game is because your dog sprite is 16 pixels wide. When the game teleports the dog to a tile next to a wall the physics engine is mistakenly detecting that a collision is happening and so wall collisions are turned off for the dog. You can prevent the bug by making your dog 15x15 pixels instead of 16x16.

I’ll open an issue in our bug tracker to make a fix for this.

Thanks @jwunderl for figuring it out!

1 Like

Here’s the issue: https://github.com/microsoft/pxt-arcade/issues/1753

I thank you very much for all of the quick responses. Reducing the pixel size seems to have eliminated the problem. However, now my sprite jitters a lot when hitting a side wall. I believe this issue was the reason I had made my sprite 16 pixels wide to begin with. Thoughts?

Hmmmm… not sure. Could be a bug with the physics detection. Could also be caused by animations. Does your sprite change size in its walking animations?

Yes, I did have it change sizes. I have fixed that and now all seems to work well. Thank you so much.

No problem! Thanks for the update!

@richard

I have a similar issue where I place an enemy sprite with x,y (relative to where the player is), and when the position happens to be a wall, it falls through. When I place the sprite a use the function 'is sprite hitting wall (left,right,top or bottom) and try move it further left or right. This function does not fire. Is that because of the issue explained above, or because the collision detection does not happen until after the current game update event?
As a workaround I will check for sprites whose top is greater than the screen height, and probably destroy them.

When sprites are placed in walls, they go into “clipping” mode and will not collide again until they are fully outside the wall.

1 Like