Godot 4.3
Why is this not printing out nothing??
The player has a node3d called head and inside head is a raycast 3d. . .
Godot 4.3
Why is this not printing out nothing??
The player has a node3d called head and inside head is a raycast 3d. . .
Raycasts are not Areas so they do not trigger area_entered
signals.
Seems like it would be better as a body_entered
signal, but without more information it’s hard to tell.
DAAAAAAAAAAAMNNNNN i will never ask chat gpt for help never again. I always get stuck on things like this. Thank you very very much homie!!!
I think is the way I am approaching this. I have a node 3d with a script to detect interactions and I don’t want to use the _process to detect when the raycast is colliding. So like, I guess I am overcomplicating this a lot.
Only a body_entered
connection with some player filtering should do, this way you do not have to get a root path to the player either.
func _on_body_entered(body: Node3D) -> void:
if body.name == "Player":
print("colliding wiht player")
Similarly your light switch root path could be a @export
variable, then assigned in the inspector.
@export light_switch: Node3D
Well, I want to collide with the ray cast. Not the player. The area 3d should detect when the ray cast is colliding with it. IDK why I’ve been 3 hours on this…
Raycasts can detect areas if set to, but areas do not detect ray casts. You will have to add your check on the player’s script.
damn, so like, i add a variable to get the light switch area, than I check if the raycast collider is light switch area, if so, do you interaction…
I humbly think a good programmer will see this code and react by damn, the hell is this shi
Sure let’s define that area as a new class
extends Area3D
class_name Interactable
func interact() -> void:
pass
Now your player script can detect interactables specifically
if ray_cast.is_colliding():
var collider = ray_cast.get_collider()
if collider is Interactable:
collider.interact()
And you can extend this Interactable with anything you like
extends Interactable
@export var light_switch: Node3D
func interact() -> void:
print("I am a light switch")
light_switch.rotate_y(0.5)
dang that looks pretty useful. thanks!