Note : Godot 3.2.3, Blender 2.83, Gimp 2.10.18.
In 2021, I've switched my attention from working on the castle itself to making
the start area 'playable'. I spent a while trying to create some shaders (and failed
miserably) and started adding more objects to interact with.
And so, I stumbled upon a new problem, aptly named "seeing through walls" :
The mouse pointer can interact with objects on the other side of the wall ! =/
Yes, a rather big problem.
The way I have things set up, right now, is like this (I talked about the why and how
before) :
So basically, anything that's not an Area node in the collision layer with value 4 is ignored by the raycast. That includes walls, which are StaticBody nodes in layer 1.
Well, you could think, that's easy to fix then ! Just include walls, floors and ceilings in the raycast.
Unfortunately, that introduces another problem ...
The StaticBody nodes for the walls are actually wider than the wall meshes themselves.
This is so that the player cannot walk up too closely to the walls (very up close,
all textures looks bad).
So, if you then attach an interactive object to a wall, you need
to make sure its hotspot Area is big enough to stick out of the wall StaticBody (else
it won't be clickable). The result :
Interacting with an object from the front is fine, but interaction from the side is broken ... Aaargh !
Another way to try and solve this problem is by using Area nodes around interactables.
The player has to be inside one of these area nodes to be able to interact with the object.
I'm pretty sure this will work, but I'm not looking forward to implementing it.
Area nodes are a bit cumbersome to use in Godot as they actually require 2 nodes,
the collisionshape has to have the 'make subresources unique flag' set, and I need to adjust the size
of the BoxShape ... For each interactable in the game. And then, wire it all up.
Anyway, each Area node adds the name of the interactable it's linked to
to an array in the Player script (in on_player_entered_area())
When the player exits the Area (on_player_exited_area()) the ia name is removed again.
The raycast now checks the array for the presence of the ia name,
instead of calculating its distance to the player.
Gah. I feel like I'm reinventing the wheel ...