0 votes

I'm making a script so that I can have the ability to have all of my nodes to know if the mouse is hovering. The way I'm planning to do this is to have a script for the main node to be checking for a child node(I named it Cursor) that will follow the mouse throughout the game and that node will be entering into Area2Ds of other nodes to allow interactions for only for the nodes that are being hovered by the mouse.
The problem that I have is that for some weird reason the main node's code cannot find that "Cursor" node. The error is this:

Parser Error: Identifier not found: Mouse

I dunno what's wrong. Here's the code, btw:

extends Node2D

var Click = Input.is_action_pressed("Interaction")

func _ready():
    Mouse = get_node("Crusor")
    Block = get_node("Block")
    areaBlock = get_node("Block/Area2D")
    set_fixed_process(true)
func MouseHover():
    if areaBlock.body_enter(Mouse):
        return true
    else:
        return false
func _fixed_process(delta):
    if MouseHover() == true:
        #this is where I'll put a command on send a Broadcast/Signal 
        #I dunno what it's called on Godot but it's a thing that sends a message to all of the nodes
        #and once the nodes recieve the message will make them do stuff
        #For example"if message 'Bla-Bla!' is recieved, do Bla-Bla"
asked Jun 17, 2017 in Engine by Noob_Maker (83 points)

Hi there! I noticed that in your code, you may have misspelled Cursor.

It is possible that is how you chose to spell your Node, but I figured I would confirm with you to be sure since I usually spell it "cursor". :D

You typed it as:

func _ready():
    Mouse = get_node("Crusor")

maybe this is what is causing the error?

1 Answer

0 votes

You have put

Mouse = get_node("Crusor")
Block = get_node("Block")
areaBlock = get_node("Block/Area2D")

But you never said what Mouse, Block and areaBlock are.

If these are variables for the instance, you need to define them like you defined Click (that will almost always be false, by the way).
If are variables that belongs to a specific function or block, define them inside that function or block.

answered Jun 17, 2017 by eons (7,784 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.