Discord
Login
Community
DARK THEME

Can someone please help me with solid collisions ?

I want to create blocks that the player cannot pass through. How do I do that? Here's an example of one of my projects https://microstudio.io/225geometrydash/renudus/. How do I prevent the player from passing through the slimes?

are you sure the slimes have there own dependent variables? if not that may be one of the couple of reasons, the player might also be a reason as well depending on what's you have in their code. but there's a chance you have an error in the code of slime for the collision not working

if you want hitboxes, id suggest the collisions lib, and to create block with collision you could make a map and use the mapHit() functions from the lib. without a map, you'd have to place them one by one and make several unique hitboxes for each group of blocks

That's right, thank you. I simply want to create a function that stops the player's coordinates at the slime's coordinates. Can hitboxes help me with that?

you can check if the player is hitting the slime's hitbox if it's an object or class. for example:

update = function()
  if keyboard.W then
    if collision(player.x,player.y+player.width/2,1,1,slime.x,slime.y,slime.width,slime.height) == 0 then
      player.y += player.speed
    end
  end
end

this is only one if the directions but it should be the general idea. you check the top most of the player if it's colliding with a slime and if it isn't, then it'll move. the only issue with this basic of collision is that small objects can be dodged, and corners of the player don't get hit too reliably

ah I see thank you

I have a functions library where I have tons of different types of collisions for different types of ways and games,

you can check it out in the explore section it is called: UTILITY FUNCTIONS LIBRARY V1.0

Post a reply

Progress

Status

Preview
Cancel
Post
Validate your e-mail address to participate in the community