How do I make a object stop when it touches another object?

What Wick Editor Version are you using?
I use 1.19.3

Describe the Problem
I’m making a rpg type game and I can’t make it so that the character stops when it hits something.

You could make a “hits” function to check if the player is touching some things.

There are other ways but i’m not really experieced with rpgs, same with platformers.

1 Like

Click me to download the example! I managed to hack this together, when the Player hits Slayer, The player will be sent back a bit, though if you want you can customize this, just a peek at the code can tell you about it! Press the right arrow key to move the player.

Example 2! I also made a version that changes the frames of the clips when player gets sent back! @KennyP

1 Like

Steps:
[1] draw object1 and convert it into a clip, then name it object1 or the name that makes more sense to your application.
[2] draw object2 and convert it into a clip, then name it object2 or the name that makes more sense to your application.
[3] Place object1 at the left and and object2 at right of the stage.
[4] Add an Update Script to object1
[5] Under that Update tab, write the following code:

this.speed = 5;
if(this.hits(object2) {
this.speed = 0;
}
this.x += this.speed;
1 Like

“this.x += speed;” doesn’t work

1 Like

Fixed. Thank you… it needs the this.

this.speed = 5;
if(this.hits(object2) {
this.speed = 0;
}
this.x += this.speed;
1 Like

can you clarify?

Did you check out the new example

1 Like

just saw it now lol i’ll try it in a little bit

aaaaaaayyyyyyyyyyy it worked! thx!

1 Like