function: is_in_group() doesn't work correctly

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By GreenPhotonRays

I am currently working on the wall run mechanic in my fps game. I am doing this with Raycasts at the left and right of the character, but it won’t work. Here is my code:

onready var RaycastRight = $RayCastRight
onready var head = $Head
var wall_run_head_angle = 20

    func _physics_process(delta):
      var collider = RaycastRight.get_collider()
       head.rotation_degrees.z = lerp(head.rotation_degrees.z, wall_run_head_angle, 0.1)
       head.rotation_degrees.z = lerp(head.rotation_degrees.z, 0, 0.1)
:bust_in_silhouette: Reply From: Wakatta

Rather than checking consistently if the raycast has a collision you might want to move your code to a signal that emits when a collision happens.

P.S GDScript is case sensitive so know that obstacles, Obstacles, oBstacles are not the same thing

Thanks for your answere! Ive now fixed it and it works pretty good.

GreenPhotonRays | 2021-10-18 11:46