0
\$\begingroup\$

I got this identifier inputevenmousebutton is not declared in the current scope; should I use another identifier?

func _ready():
    position = get_viewport_rect().size / 2
    direction.x = rand_range(-1, 1)
    direction.y = rand_range(-1, 1)
    direction = direction.normalized()
    width = get_viewport_rect().size.x
    height = get_viewport_rect().size.y

func _process(delta):
    position += direction * speed * delta
    if position.x < 0 or position.x > width:
        direction.x = -direction.x
    if position.y < 0 or position.y > height:
        direction.y = -direction.y

func _on_UFO_input_event( viewport, event, shape_idx ):
    if event is InputEvenMouseButton and event.button_index == 
        BUTTON_LEFT and event.pressed:
        direction.x = rand_range(-1, 1)
        direction.y = rand_range(-1, 1)  
        direction = direction.normalized()
        position.x = rand_range(1, width -1)
        position.y = rand_range(1, height -1)
        speed += 5
\$\endgroup\$
2
  • \$\begingroup\$ InputEventMouseButton. You wrote "even" instead of "event" \$\endgroup\$ Commented Jun 3, 2019 at 21:48
  • \$\begingroup\$ @trollingchar that looks like an upvote-worthy answer to me! \$\endgroup\$
    – DMGregory
    Commented Jun 3, 2019 at 22:03

1 Answer 1

3
\$\begingroup\$

The parser tells you that it is not recognizing this word in the current context.

Some keywords are defined by you, others are defined by the language/framework. In this case, it is one defined by Godot. What should be done, here, is that you should re-read the error message it's giving you; you'll realize that "event" is not spelled right.

Changing InputEvenMouseButton to InputEventMouseButton should fix this error.

If the word had been one of those that you decided, then you'd have to make sure that all the variable names matched with those you defined. This can create headaches sometimes, and one has to be patient.

Should I use another identifier?

Given what I said, no, you should find the issue with the identifier you're trying to use, because it's defined by Godot.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .