Author Topic: Objects Not Being Deleted after channel leave  (Read 2966 times)

vzdemon

  • Guest
Objects Not Being Deleted after channel leave
« on: March 19, 2013, 07:44:23 AM »
From what i understand all the objects that a client spawned should automatically delete from the scene for all clients. that is not happening in my case, player objects are staying in the scene after the player quit and when her rejoins he has 2 player objects, one of which he controlls. how do i get rid of these objects i even tried putting the following the their scripts:
  1. void OnNetworkLeaveChannel() {
  2.         TNManager.Destroy(gameObject);
  3. }
  4.        
  5. void OnNetworkDisconnect() {
  6.         TNManager.Destroy(gameObject);
  7. }
  8.  

but they still dont die. what am i doing wrong here? they both have TNObject and TNAutoSync on them (TNAutoSync has all bools unchecked).
thanks for reading.

Deozaan

  • Newbie
  • *
  • Thank You
  • -Given: 44
  • -Receive: 4
  • Posts: 42
    • View Profile
    • Deozaan.com
Re: Objects Not Being Deleted after channel leave
« Reply #1 on: March 19, 2013, 11:55:27 AM »
OnNetworkLeaveChannel and OnNetworkDisconnect don't get called until after you have left the channel or disconnected from the server. Thus, you can't affect anything that is still in the channel or on the server after you're no longer there.

When you create the player object, pass in false as the persistence bool. e.g.:

TNManager.Create(playerObject, position, rotation, false);

vzdemon

  • Guest
Re: Objects Not Being Deleted after channel leave
« Reply #2 on: March 22, 2013, 11:02:07 AM »
I get the error: "Assets/Scripts/BotSpawner.cs(12,35): error CS1501: No overload for method `Create' takes `4' arguments". Is there another way to turn off persistance?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Objects Not Being Deleted after channel leave
« Reply #3 on: March 22, 2013, 06:19:16 PM »
Deozaan mentioned that you should use TNManager.Create, not BotSpawner.Create. I dont know what BotSpawner is.

vzdemon

  • Guest
Re: Objects Not Being Deleted after channel leave
« Reply #4 on: March 23, 2013, 07:06:18 AM »
BotSpawner is the name of the script and class that calls TNManager.Create. there is not such method 'Create' of class 'BotSpawner' unity was referring to TNManager.Create(), it said that is didn't find an overload for it that accepts 4 parameters