Can you create a raycast and get a collision in the same frame?

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

When you create a raycast it normally doesn’t collide with anything until the next loop through _physics_process() etc. I was wondering if there is any way around this?


func _physics_process():
    if not ray_created:
         ray = raycast.instance()
    var collision_info = ray.collide() #if ray was just created it won't collide until next time around.
:bust_in_silhouette: Reply From: exuin

Call force_raycast_update.