Discuss Scratch

Tsunami_trouble11
Scratcher
80 posts

Player clipping into the floor

Hello! I’m working on a game called Lumen, where you walk around as a little robot collecting solar energy to build things. Anyways, the player regularly clips into the ground, especially after falling.


How Collision Works

First, a broadcast is sent out to start the raycaster. The raycaster sends out rays in directions 0, 90, 180, and -90. Then it records the distances from the player to a list. Then, the Lumen (player) sprite adjusts the X and Y velocity variables according to inputs and gravity. The collision script is run after, where it checks if one of the distances is too close. If that’s the case, the velocities are set to 0 and the player’s position is adjusted to try and stop the collision.

Thank you for reading!
Game

Note: The items in the distance list go in this order: up, left, down, right

Last edited by Tsunami_trouble11 (Sept. 9, 2023 03:57:23)

griefercube
Scratcher
500+ posts

Player clipping into the floor

I’m unsure of what caused the bug, but I’ve managed to fix it with these scripts (you’ll know where they go):




Tsunami_trouble11
Scratcher
80 posts

Player clipping into the floor

griefercube wrote:

I’m unsure of what caused the bug, but I’ve managed to fix it with these scripts (you’ll know where they go):




Thank you so much!! I’ll put in credit in the main project (the one on not on my alt)

Powered by DjangoBB