This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

I'm making a procedurally generated 3D world using chunks that generate collisions through MeshInstance3D.createtrimeshcollision(), and they're working as expected. Below are screenshots that show the current setup of the generated chunks, the Raycast3D, etc.

The chunk generation, and the RayCast3D config

However, when I try to use a RayCast3D to get the terrain's current Y coordinate, it doesn't seem to detect it, despite apparently being on the correct collision layers and masks. The below screenshot has the player below ground, and the raycast pointing up, and it should have detected the terrain above, but doesn't.

In game, RayCast3D isn't detecting the terrain above

I set it up to print whatever it detects a collision with, and it even detects other objects, everything but the terrain itself. Please help, and thank you in advance!

Godot version v4.0.beta1.official [20d667284]
in Engine by (15 points)

1 Answer

+2 votes
Best answer

I had a very similar problem. It seems to be solved by enabling "collision with areas" on the Raycast3D.
I am not sure though if the StaticBody3D is intended to be counted as area or if it's a bug. Maybe its because it's not a closed object but a plane that has no inside.
Hope this helps.

by (48 points)
selected by

Thanks for your answer, and your ideas could actually help someone with a similar problem.

But I did manage to solve this issue on my own, and the thing was that the RayCast must not only be set to detect collisions from inside, but also the "side" of the terrain plane matters for collisions, as if it's the "wrong" side (sorta like the side the plane doesn't draw) the RayCast won't detect it. Setting one or both of these parameters to adequate values should solve the issue.

Basically either make your RayCast detect collisions from inside areas, or make the area report collisions from both sides, or both.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.