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

Added Spawner Timer Node #33610

Open
wants to merge 3 commits into
base: master
from

Conversation

@Coldragon
Copy link

Coldragon commented Nov 13, 2019

-It spawn selected Scene at a certain rate.
-You can make it endless or with a limited quantity.
-You can stop automatically the timer if it failed to spawn (Scene error or quantity over).
-You can manually Spawn with spawn() (it will decrements the spawn quantity by one if it's not endless). It return the node created and add it automatically as child to the Spawner.
-You can spawn_bypass() to spawn regardless of the Spawner being endless or quantity=0. It return the node created and add it automatically as child to the Spawner.

A signal is emitted when one scene is Spawned and it have as a parameter the Node.
spawned(node: Node)
A signal is emitted when you spawned the full quantity
spawned_all()

Coldragon added 2 commits Nov 13, 2019
It spawn a Scene at a certain delay or with .spawn(). A signal is emitted everytime it happend with the spawned node as argument.

.
It spawn a Scene at a certain delay or with .spawn(). A signal is emitted everytime it happend with the spawned node as argument.

.


.
@Calinou

This comment has been minimized.

Copy link
Member

Calinou commented Nov 13, 2019

I don't see much point in having this in core. All this can be implemented in GDScript in less than 100 lines of code. You could pack it in a nicely self-contained asset to reuse it across projects.

PS: Large features should be discussed in godot-proposals before implementing them, so that we can reach a consensus.

@Coldragon

This comment has been minimized.

Copy link
Author

Coldragon commented Nov 13, 2019

It was my first try with editing the engine and I though that idea might be usefull.
I will create a godot-proposals later to discuss about that and i'l explain the main purpose of that and some upgrade I'm not sure how to handle. (Example : Position of the spawned Scene, the node itself is not a Node2D so can't use the node pos)

@Zireael07

This comment has been minimized.

Copy link
Contributor

Zireael07 commented Nov 14, 2019

I think it's more suited to external addons, such as @willnationsdev's Godot-NEXT repo

@KoBeWi

This comment has been minimized.

Copy link
Contributor

KoBeWi commented Nov 14, 2019

Eh, so this is basically a standard Timer with "conveniently" supplied PackedScene to spawn.
...
That doesn't sound useful. A standard Timer is actually better, because your Spawner can only instance something as a child of that spawner. It's not Node2D nor Spatial, so the new object won't even have a correct position. So you need to go out of your way and manually reparent the spawned node using the signal. Heh. You can of course add more functionality to make it more flexible, but why would it have to be in core.

This is the GDScript implementation of actually useful part of the spawner:

func _on_Timer_timeout():
    var node = preload("MyScene.tscn").instance()
    add_child(node)

I highly doubt that creating a formal proposal would help it xd

@girng

This comment has been minimized.

Copy link

girng commented Nov 14, 2019

Can't this already be done with gds using Timer?

@Xrayez Xrayez mentioned this pull request Nov 17, 2019
0 of 14 tasks complete
@Xrayez

This comment has been minimized.

Copy link
Contributor

Xrayez commented Nov 17, 2019

@Coldragon feel free to discuss your proposal at non-official godot-ideas repository which targets proposals that are nice-to-have to be implemented, because godot-proposals mostly targets core development. You do happen to write stuff in C++ so you could as well implement it as a module if you want to get familiar with C++ engine development side.

There are a number of perfomance-critical aspects of spawning which can be solved, for instance how would you go about spawning collision bodies which don't collide with existing level geometry (as well as already-spawned bodies)?

I'd personally implement this in core myself but it really has to be a universal solution which covers a lot of use cases and which is configurable, and for that you need to know what possible behavior people expect from a node spawner to fulfill those needs, which could be a lot of work actually, that's why I think the godot-proposals repository asks you that your feature is proven to be useful in existing projects before opening a proposal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
7 participants
You can’t perform that action at this time.