Godot Version
`4.2.2
Question
I’m trying to bring an object into another scene and I want the raycast to detect if it is an intractable object, if it is, i want it to prompt a message. The problem I’m having is its tell me raycast isn’t being declared, but I am declaring it.
this is my "interactable " script
class_name Interactable
@export var prompt_message = "Interactable"
#double check that its .tscn
var Orange = preload("res://orange.tscn")
func _ready():
pass
func _input(event):
if Input.is_action_just_pressed("my action "):
var collider = raycast.get_collider()
var instance = Orange.instantiate()
add_child(instance)
# Set the position of the object
instance.position = self.position + Vector3(-15, -8, -10)
if raycast and raycast.is_colliding():
# Get the object the ray is colliding with
if collider is Interactable:
print("Found interactable object: ", collider.name)
collider.prompt_message = "Press E to interact"
func _physics_process(delta):
pass```
anything helps