Code crashes for some reason

//for(let wall of scene)
moveAngle(this,this.gravAngle,1)
if(this.floorDect.hits(_floor,project.hitTestOptions)){
let hit = this.floorDect.hits(_floor,project.hitTestOptions)
this.gravAngle = Math.atan2(hit.overlapY, hit.overlapX)
this.walkAngle = Math.atan2(
hit.intersections[1].y-hit.intersections[0].y,
hit.intersections[1].x-hit.intersections[0].x
)
moveAngle(this,this.gravAngle-180,1)
}

if(isKeyDown(“d”)){
this.x+= Math.cos(this.walkAngle)*this.speed
this.y+= Math.sin(this.walkAngle)*this.speed
}
if(isKeyDown(“a”)){
this.x-= Math.cos(this.walkAngle)*this.speed
this.y-= Math.sin(this.walkAngle)*this.speed
}

so in my player clip there is a brown box called floorDect
Im using convex collions and am trying to get the 2 points where it this the ground so i an then use that to get an angle so the player can run up slopes.

I think im using the intersection array wrong?

You didn’t include functions and variables that you used, that means I can’t help you. Here’s a list of what’s missing.

  • Variable named _floor.
  • Function named moveAngle.

But I can tell you that you need to update your use of this.hits(that). The projects’ hit test options are the default options in running the hits function.

_floor is a clip. its just a triangle

here’s the dfinition for move angle

window.moveAngle = (clip,angle,spd) =>{
clip.x += Math.cos(angle* (Math.PI/180))*spd
clip.y += Math.sin(angle* (Math.PI/180))*spd

}