#It s spawned in when the player breaks a

1 messages · Page 1 of 1 (latest)

sterile horizon
#

so, you have a script that spawns that tileDropPRefab, right?

scarlet mirage
#

Yes

sterile horizon
#

you declare this public PlayerBehavior player; in the spawner script, and the tileDropPrefab's script

#

then, since the spawner is in the scene, you can assign the player to its public PlayerBehavior player; in the inspector

#

in the code where you Instantiate the tileDropPrefab, you pass the spawner's player reference to the tileDropPrefab.

#

the tileDropPrefab script should have something like

public void Initialize(PlayerBehavior player)
{
  this.player = player;
}
#

and the spawner Instantiate code would be like

TileScript spawnedTile = Instantiate(tileDropPrefab);
spawnedTile.Initialize(player);
scarlet mirage
#

Thanks

#

It works now