Godot Version
v4.3.stable.official [77dcf97d8]
Question
Right, so I’ve got a simple player (CharacterBody2D) hanging out on a tile map. Next to the player are a rock (RigidBody2D) and a seesaw (two RigidBody2Ds joined by a PinJoint2D.
Although the player can jump and collide nicely on all three things (the tiles, the rock, and the seesaw), I cannot get GDScript to tell me that there was indeed a collision and give me the type of the collider, when the player touches the seesaw. I’m very new to Godot so I’m not sure this is intended behaviour, a bug, or if I’m just going the wrong way about this (my goal is to detect where the character touches the seesaw with a raycast, and apply a force there to make it tilt).
Here’s the scenes for the player, the rock, and the seesaw:
I’m referencing the RayCast2D attached to my player like so:
@onready var ray = $RayCast2D_down
In the player’s _physics_process(), I have this:
if ray.is_colliding():
var collider = ray.get_collider()
print("Collider type is: ", collider.get_class())
When the player is resting on a tile, it prints:
Collider type is: TileMapLayer
When the player is resting on the rock, it prints:
Collider type is: RigidBody2D
When the player is resting on the seesaw, it prints nothing, which I take as meaning that ray.is_colliding() is returning false for some reason.
How do I detect that the player is indeed touching the seesaw?