How to make a wall using code?

i have a few coding experience and im new to the wick editor forums and i wanted to create a game but there’s one problem i don’t know how to code walls… like objects can pass through them it’ll be great if you give me an example of one thank you for reading!

Here’re the examples:

  1. With hit test (Hard coded options is broken in 1.17 and up)
  2. Without hit test (a more advance version) (no pass through)
1 Like

Thank you!

welcome to the wick forms!
here are the instructions:

  1. make a wall and a character
  2. name your wall
  3. open the update script in the character
  4. add this code (you may change it if your wall is in a different axis)
    if(this.hitTest(wall1) ) {
    this.x -=10; // stop moving right
    }
1 Like

thanks a lot this works too but only great for a top down game which im planning too make
but what about 2d games like endless running or like a flat 2d screen mario like game
because the walls only push which make the character bounce up and i learned a gravity code soo is there any other code i can use to make that game?

oh yeah, sorry that i didn’t tell you this but you can change the bottom code to work for any direction.

2 Likes

making walls and stuff.wick (335.0 KB)

if you’d prefer a simple and perfect wall, I made this in a couple of minutes, it might help:
perfect simple wall.wick (2.1 KB)
(use arrows to move)

2 Likes

Thank you what a great tutorial!

1 Like