Best Way to Make Solid Objects?

Hey all,

I received an email asking for ways to make solid objects (meaning no other objects should be able to go through the solid), so I figured I’d survey the crowd to see if anyone has more efficient ways to make this happen.

The solution I came up with is to add a block of code to all the objects in the game saying that when they are in touch with the solid, they will bump back, but this would require the person to add this block of code to all the objects. Are there any easier ways?


I’m not sure - I’d be interested to learn myself how to do this easily! - but I’ll tag @Spy_Guy_96 since he’s made a bunch of platformers with a really good collision engine. :+1:


You can just use one object but use clones, then you don’t need to repeat that code


Mr. Spy Guy is the best at these
Everyone uses their code for platformers


True ikr, but for some reason it doesn’t work for me so I had to add in some extra stuff


The way I do it is pretty complex. But to make it easier to understand, I basically use 2 variables that track the players next position. Then, if the object with collision realises that the player next position is inside the object, it will change the 2 variables to be right next to the tile.


@Yuanyuan You can make what is called clones.
Add the block in one object and all its clones will follow that rule


Generally, for good collision engines - even with game engines outside of Hopscotch - it’s pretty crucial to have the next position of the moving object to compare it to the solid, so that next position can be adjusted for, so it collides and stops on a solid instead of bouncing on it. It’s the difference between good collision and weird floaty collision, ie. something like this.

And then, yeah, like everyone else is saying, you could just add that collision code into an ability, or use clones, to use that code everywhere else!


You can use custom blocks (purple) and add the block of code to it, so you don’t have to copy and paste the code into all of your solid objects.


If you make it a custom rule it’s easy to add to all objects and would be pretty good. The main problems are figuring out how best to detect the two objects touching and how to push them away from the object.

For a lot of uses, the touching block would work if you time it right. Importantly I think (I’m not sure) that you’d need to move the object first (put the moving code above the touching rules) then the touching, then some sort of code to push it out.

That last part is the hardest part, I’m not sure how best to do it and end up having to fiigure it out every time I want to use it so any help would be helpful.


I don’t know how to but I have made it in one of my projects. I’ll have to look for that project. Well I only made it solid on two sides.


Wow this topic is full of long replies talking in the super secret smart people language…

I would say that you can make it into a purple block so it would be easier.


Spy_Guy_96 has a really useful collision code for squares, which work well with clones.


  • no constant glitching will occur when the object is in contact with the object
  • Works with clones, so you don’t need to copy the same code to other objects


  • some code re-arrangements may be required to make this all work properly
  • separate code for other object shapes are required

I was wondering, @Yuanyuan, what is your hopscotch email?
is it


yep, it is!


Not me I made mine by myself

So like collision codes?
I mean you could do when bumps object check once if X pos = X pos +100 yeah but that would take a while. I’ve been wondering how to do that.
FoxProductions has some really good games that use that

What do you mean Solid

1 Like

The easiest way I can think of is a custom block…

With this code:

Purple Custom Block:

   When game starts{
      Set [(self) type] to [whatever you want... solid=1 non-solid=2
   When [anything] is touching [self] {
      Check once if [(self) type] = [1] {Broadcast message named [Solid hit]} 

When [anything] is not touching [self] {
      Check once if [(self) type] = [1] {set var [var1] to [self x position]; set var [var2] to [self y position]

When I get a message [Solid hit]{
      Set position x[var1] y[var2]

Is this clear? This purple block would need to go into every object… I haven’t tested this code but it should work…

Here are some examples

I have two objects. The first object is a can… you can’t slide your hand through a can. But my second object is just a picture of a slice of bread made by a projector :film_projector:. The second object is NOT a solid, so you can slide your hand through it. It is just a projection… however, the first object is a solid, you can NOT slide your hand through it…

Now back to hs…

In Hs currently objects can pass over/through other objects. Making an object a solid would mean that the object trying to pass over/through the object would stop once it hits the (a) solid object.

E.g. I have two objects: Bear and Robo.

Robo is set as a solid and positioned at x:300; y:500

Bear is positioned at x:0; y:500

Bear’s code is as follows:

When Game Starts
     Move forward by 1000

Bear’s y position is the same as Robo’s, meaning that they are on a collision course. Bear’s code makes bear move forward by 1000, bumping into robo after the first 300. If robo isn’t a solid, bear would just continue past robo by either moving in front of robo or behind robo (depending on their z index values)… Note: bear’s y position would not change.

However, if Robo is a solid, when bear bumps into robo, bear would stop moving.

Phew :sweat_smile: that was a lot! :yawning_face:… I hope I helped you understand.