Duplicated Player prefab when changing scenes

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
will_888
Posts: 26
Joined: Mon Feb 07, 2022 4:09 am

Duplicated Player prefab when changing scenes

Post 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!
User avatar
Tony Li
Posts: 22108
Joined: Thu Jul 18, 2013 1:27 pm

Re: Duplicated Player prefab when changing scenes

Post 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.
Post Reply