|Topic was automatically imported from the old Question2Answer platform.
Honestly it’s several questions in one, if this is not possible please tell me for next questions. I am quite initiated in Godot but I have certain notions. I’m in the part of creating objects for the player to collect, for now only coins. This is the structure of the scene where it all happens.
However, I have encountered a small problem. First I present the way I have programmed the coin scene (It should be clarified that I only place the code corresponding to the currency.):
The way to put them on my level is as follows:
export (PackedScene) var Coin
CoinPos = $CoinSpawn.get_children()
for co in range(len(CoinPos)):
coin = Coin.instance()
coin.position = CoinPos[co].position
Based on the position nodes I place the coins with a for, there will be the number of coins according to the number of position nodes. All right so far, now I’ll show you the coin scene code:
$Collision.call_deferred("set", "disabled", true)
Everything works fine, I manage to pick up the coins and they disappear, but the problem came when I saw that I couldn’t connect a signal (
get_coin) to the main scene because as such it wasn’t instantiated in this one, but it packs up (I still don’t grab the thread to the packing up of scenes).
My doubts are:
- Is it possible to get what I’m looking for with the code this way or
should I change?
- Is the way the coin scene is structured okay? I mean the use of an
- (Extra question) Can I apply gravity to the coins? I mean, the way I
have programmed all the coin is static at its spawn point. I would
like that after the coin is generated it is quiet and it is above
the floor, like the player, I tried that the root node of the coins
was type RigidBody2D but although I managed that the coin achieved
that effect, the player pushed them and didn’t grab them.
I repeat, if there are too many things you can help me just by connecting the coins to the main scene, because what I am looking for is to generate several coins in specific places, thank you.