Author Topic: Change Persistent  (Read 2133 times)

voncarp

  • Jr. Member
  • **
  • Thank You
  • -Given: 13
  • -Receive: 2
  • Posts: 91
    • View Profile
Change Persistent
« on: November 25, 2014, 01:20:53 PM »
How do I change the persistent flag after it has been set?

I have a player hit a trigger and spawn in some enemies.  The player dies so I don't want the enemy to disappear so I have the persistent flag set to true.

However, if I have the player kill the enemies I destroy the enemy.  Then I have another player connect and automatically he gets disconnected and I get:

[TNet] Trying to execute RFC #33 on TNObject #2752505 before it has been created.

I suspect the player trying to connect is getting booted because of that error.

However, before I am booted I can see the enemies in the hierarchy in the editor.  So, even though they were destroyed by the initial player.  They are still around.  How do I clear them out?

Additionally, often when I disconnect and then attempt to log back in my player seems to want to spawn back where he initially left even though I have persistent set to false.

I spawn in my character with this:

  1.         IEnumerator SpawnPlayer() {
  2.                 while (TNManager.isJoiningChannel) yield return null;
  3.                 TNManager.Create(player, spawnSpot.position, spawnSpot.rotation, false);
  4.                 _playerTransform = player.transform;
  5.         }

Again, thoughts on how I can l clear these out?
« Last Edit: November 26, 2014, 04:55:53 AM by voncarp »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Change Persistent
« Reply #1 on: November 26, 2014, 09:20:55 PM »
Persistent flag on what? You can't alter the persistent state of objects, and shouldn't do anything with channels either, so what are you changing?

To destroy things, use TNManager.Destroy. If you just use Object.Destroy, then you are only removing them locally.

voncarp

  • Jr. Member
  • **
  • Thank You
  • -Given: 13
  • -Receive: 2
  • Posts: 91
    • View Profile
Re: Change Persistent
« Reply #2 on: November 27, 2014, 04:59:20 AM »
TNManager.Destroy was what I was looking for. Thanks.