Wallrunning but on a particular layer

Godot Version

4.5.1

Question

hey guys so i’ve been playing around with this controller i found and i’m trying to make the wallrun function only work on meshes on a particular collision layer this is the code for reference

func wallrun(delta : float):
   var leftWallNormal : Vector3 = get_wall_normal().rotated(Vector3.UP, PI/2)
   var rightWallNormal : Vector3 = get_wall_normal().rotated(Vector3.UP, -PI/2)
  var newDir : Vector3 = leftWallNormal if leftWallNormal.angle_to(wallrunStartVel) < rightWallNormal.angle_to(wallrunStartVel) else rightWallNormal
velocity = newDir.normalized() * clamp(wallrunStartVel.length(), speed/2, speed * 2.0)
if prevWallNormal != get_wall_normal():
	velocity -= get_wall_normal() * 2
else:
	velocity -= get_wall_normal() * 2
velocity += Vector3.UP * (wallrunCurve.sample(wallrunPoint) * wallrunHeight)
move_and_slide()

if wallrunPoint < 1.0 and is_on_wall_only():
	wallrunPoint += delta / wallrunTime
else:
	changeState(MOVESTATES.AIR)
	resetWallRun()

if Input.is_action_pressed("jump"):
	prevWallRunPoint = position
	changeState(MOVESTATES.AIR)
	applyForce((Vector3.UP + get_wall_normal()/2).normalized() * 12.0)
	resetWallRun()

prevWallNormal = get_wall_normal()