#A packed scene only instances once when a script is added to it.

21 messages · Page 1 of 1 (latest)

timid veldt
#

In a game I am working on, I have a tile that a mapgenerator script arranges according to the map algorithm I choose.

Each tile is a scene consisting of 2D tile sprite and an attached script tile.gd which contains a number of variables meant to be unique to the tile, such as position, text , is_discovered and so on.

Before I added the script the tiles were just sprites saved as scenes. The algorithm that places them has no issues with placing them in the correct order. Once I add the script however, the exact same algorithm now spawns what seems like only one tile in one spot.

I cannot figure out why.

The function that loads the map is attached.

azure peak
#

I'm. Not sure if I understand your problem, but try looking for the resource tab in the inspector and toggle ON the "local to scene" property

#

If your problem is having the same image of the tile spawned, them look for the resource tab of the texture, selecting your node and then it's texture.

#

If doesn't work, try doing the same for the script resource.

#

Can't help you more than this xD

timid veldt
#

I looked at what you described and tried it and it did not work. Wifi is currently down. Will get on it tomorrow and see if I can send screenshots of the different behaviors

timid veldt
#

This is the behaviour when I add a script to the tile scene

#

This is the tile scene in question

timid veldt
#

The rest of the tiles the map needs get generated

timid veldt
azure peak
#

Can you show the script you are attaching to the tiles?

timid veldt
#

I should’ve thought of that. Crap. Will go to the wifi spot tomorrow and upload the screenshot

timid veldt
#

Actually I can just type that here since the script is so simple

#
extends Node

var tile_name = “ “

var icon = null

var position = null

var time_consumed = 0
var energy_consumed = 0
var can_fast_travel = false
var can_horse = false
#

It s basically just full of variables

#

@azure peak

robust haven
#

the script is extending Node instead of Node2D

#

my guess is that what's actually happening is that all of the tiles are getting instantiated, but since the script isn't extending Node2D it doesn't actually know what to do with position so they all just get stacked on top of each other in the same spot

timid veldt
#

I’ll give this a trygdthumbsup

timid veldt