I need help with my collision

I am making collision in my topdown game but every time I touch the wall my character flickers back and forth, is there better collison code then
if (this.hits(that) {
something
}

make it move one less than the amount it overlaps
to make it work in both directions, you can use

this.x+=hitInfo.overlapX-Math.sign(hitInfo.overlapX)

However, the Math.sign function isn’t in wick for some reason, so you can define it like this

Math.sign=function(num){
    if(num){
        return num/Math.abs(num)
    }
    else{
        return 0
    }
}

The if statement is because if the input equals 0, it will return undefined because that’s what happens when you divide by 0

@Donut could you send a wick file?

You can use @awc95014 engine using only the collision functions.

I tried doing that and it still does nothing, did I do something wrong? if so could you point me to what I should do?
here is the wick file My Project10-5-2022_16-25-19.wick

nevermind I found a way

1 Like