RayCast node always return null

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

I’m using RayCast node to check the object is grounded. Here’s the setting:

RayCast node is placed near by ground and the length enough to collide with ground. Also RayCast node is enabled.

RayCast node is child node of FPSController node, and here’s the code of FPSController that processing grounded logic:

onready var ground_check_raycast: RayCast = $GroundCheckRayCast

func _physics_process(delta):

func process_grounded(delta):
    var hit_collider = ground_check_raycast.get_collider()

When I run the game, first few times it return floor, and then immediately return false and never return floor back.

** Debug Process Started **
OpenGL ES 3.0 Renderer: GeForce GTX 1070/PCIe/SSE2

I have no idea why this won’t work. Is there a something that I missed?

P.S. Floor object has static body and CollisionShape.
P.P.S. Using Godot 3.1.1

I don’t find FPSController in the docs. Is this some item of the assetlibrary?
Does the FPSController react to Gravity? Maybe it fell through the floor? Watch its position (y).

Is the floor collision shape at scale 1,1,1? (and the parent body)
If not then try to set the shape at scale 1,1,1 and edit the extents of the shape instead to resize it. At least on older godot versions there were odd reactions with collsions when people scaled shapes in very “uneven” ratios (i.e. 100,1,100).

wombatstampede | 2019-11-01 11:39

Thanks for comment, I solved this problem by slightly moving up the raycast node. Still don’t get it why it didn’t worked, anyway it solved.

You don’t have to concern about the name. FPSController is just name of the node and script. And yes, it reacts to gravity, FPSController is renamed KinematicBody node.

The floor is not scale 1,1,1, I streched to make more like plane in Unity. Maybe I should try with 1, 1, 1 scale. Thanks.

rico345100 | 2019-11-01 14:23