To learn Godot, I decided to try to make an isometric 3D game on mobile as a first project.
I have gone through numerous tutorials, documentation, and the intricacies of Google, but I cannot resolve my problem, so I am asking for your kind help.
Below is how the main scene is configured:
(Node3D) World
(DirectionalLight3D) DirectionalLight3D
(NavigationRegion3D) NavigationRegion3D
(Node3D) Terrain
(Node3D) CameraGimbal
I created a Terrain on Blender with a certain relief (hills, mountains).
And imported it like this in Godot:
(Node3D) Terrain
(MeshInstance3D) Terrain
(StaticBody3D) StaticBody3D
(CollisionShape3d) CollisionShape3d
I try to make the height of the camera (Y axis) always at the same distance from the ground.
So, if the camera moves over a mountain, the height of the camera will follow the curve.
I tried adding a RayCast:
(Node3D) CameraGimbal
(Node3D) InnerGimbal
(Camera3D) Camera
(RayCast3D) RayCast3D
With Target Position Y = -100
In order to detect the ground and its distance from the camera, but I can’t get the Raycast to detect the terrain, even when the camera collides with the terrain.
(RayCast is enabled, as well as Collide with Aeras and Bodies)
Does using a RayCast suit my needs?
If so, what is missing for my RayCast to collide with my ground (CollisionShape3d)?
Thank you very much in advance for your time and help!
Thanks a lot for sharing this archive that you updated.
This is a perfect example for a 3D-isometric game with one character, but I’m trying to do it with a free camera (which detects changes in ground height to keep the same Y distance from the ground).
Should I create an invisible CharacterBody3D, that can only collide with floor?
(Or same with another kind of 3d object ?)
Is there other ways to detect the relief (Y) of my terrain per X.Z position ?
(Because I can only get position of the global object…)
I have extended another example, via HightMapShape3D in CollisionShape3D I was able to check “distance_to_camera” and “height_above_camera”. Godot has a useful debug function, it RayCast turns red when it hits an object.