Page 1 of 1

Duplicated Player prefab when changing scenes

Posted: Sun Feb 12, 2023 3:31 pm
by will_888
Hello!
I'm having trouble with duplicated Player prefab when changing scenes when using the Dialogue System Trigger Event set with "On Enable".

Use case (RPG style game battle, à la Final Fantasy VII): the battle ends, the player clicks on Exit Battle button, then the button ENABLES a DialogueSystemTriggerEvent on a GameObject. The Event, set on "On Enable", then transports the player prefab back to the previous scene. Now the player prefab is duplicated.

When I'm using the ON TRIGGER option on Dialogue System Trigger Event, I'm fine and dandy.
Example: the player enters a house from the city street, the goes back to city street (using Player Spawnpoint). No duplicate.

Can I get support on this?
Thanks!

Re: Duplicated Player prefab when changing scenes

Posted: Sun Feb 12, 2023 4:29 pm
by Tony Li
Hi,

Is your player prefab marked Don't Destroy On Load? If so, can you change it so it's not Don't Destroy On Load? If not, you'll need to do one of these things:

1. Don't have a player prefab in your battle or world scenes. Instead, instantiate it and mark it Don't Destroy On Load in some other scene.

2. Or use a script on your player to determine if another player GameObject already exists in the scene; if so, delete one or the other.