Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calling Self not working properly? #45866

Closed
TheKnittedAcorn opened this issue Feb 10, 2021 · 1 comment
Closed

Calling Self not working properly? #45866

TheKnittedAcorn opened this issue Feb 10, 2021 · 1 comment

Comments

@TheKnittedAcorn
Copy link

TheKnittedAcorn commented Feb 10, 2021

Godot version:

Godot Engine v4.0.dev.calinou.06ae14dd8

OS/device including version:

Win10 Home x64 desktop PC

Issue description:

New to GDS. Set up to do a tutorial or two with 4.0.

One line of code giving me resounding issues, in which a Timer needs to call on self.

As you can see from the screenshot, I did a setup in the stable build of Godot 3.2.3 of the same tutorial with the exact same code, and it worked perfectly fine.

errorsgalore

As you can see, the 4.0 version is bugging out pretty badly. For some reason I'm not even seeing a list of methods and Node2D.tscn isn't properly indicated in the FileSystem? Am I missing something? Am I crazy? Is there some new-fangled thing I'm not finding?

Steps to reproduce:

  • Make Node2D
  • Child Sprite2D and Button to Node2D
  • Child Timer to Sprite 2D
  • Add Signal "pressed()" to Button and connect to Sprite 2D
  • Add script as written to Sprite 2D:

extends Sprite2D

var speed = 400
var angular_speed = PI

func _process(delta: float) -> void:
rotation += angular_speed * delta
var velocity = Vector2.UP.rotated(rotation) * speed
position += velocity * delta

func _on_Button_pressed():
set_process(not is_processing())

func _ready():
var timer = get_node("Timer")
timer.connect("timeout", self, "_on_Timer_timeout")

func _on_Timer_timeout():
visible = not visible

Minimal reproduction project:

Godot Project 01.zip

@YuriSizov
Copy link
Contributor

In 4.0 there is a new version of GDScript and signals are no longer connected with strings. Functions are also first class citizens now and can be passed by reference as a Callable object.

Read more in the old PR #39093

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants