Hello, is there a way to make better walls, like if you touch a wall and you click up you can’t move with some of the examples I saw so, is there a way to make a wall that you can still move in directions that there is no wall
I’ve done something like this before which uses the overlap piece of the hit test you can make a fairly simple but good wall system
In default of player clip
this.walls = [];
In update of player clip
for (let i = 0; i < this.walls.length; i++) {
let hitInfo = this.hits(this.walls[i], {overlap:true});
if (hitInfo) {
this.x = this.x + hitInfo.overlapX;
this.y = this.y + hitInfo.overlapY;
}
}
In the walls’ default script
CharacterClipName.walls[CharacterClipName.walls.length] = this;
Of course replace CharacterClipName with the name of your player clip
It basically gets the overlap of your player on every wall and moves you so that you aren’t in the any walls, and this works with multiple walls but only rectangles (circles are also easy but you need to specify to use a circle)
Hope this helps
Wow😲 how did you learn that
i know one, but idk if it’s effecive or not. ima sure it isnt.
i’m giving you a logic, because i’m bad at js, to be honest.
in the controls, we say if key pressed, then, we add a nested if.
inside the nested if, we say the hit with the wall code.
then, we type the oposite direction of the movement when the key pressed.
then, you movement of where should it go when the key pressed
Logic: our speed, eg: 10.
when we hit a wall, we need to reverse it, making it like a boulder eg, -10
Actually, tis glitches, but, it can be fixed. i took this knowledge in scratch, so that counts.
This can probably work…
if (!this.hits(wallUp)) { if(key==="up") { this.y-=5}
I haven’t tested it but it should work…