Author Topic: Separate GameObject from parent when player leaves  (Read 1967 times)

djray2k

  • Jr. Member
  • **
  • Thank You
  • -Given: 4
  • -Receive: 4
  • Posts: 74
  • Blockey Hockey!
    • View Profile
    • Walking Talking Grilling Bear Studios
Separate GameObject from parent when player leaves
« on: April 09, 2014, 04:45:54 PM »
  • I have a player game object that is created when a player joins and is not persistent.
  • I have a ball game object that is created when the game starts and is persistent.
  • When a player has the ball, the ball's parent is the player.
  • When the player exits while holding the ball, the ball gets deleted.

I tried just separating the ball when OnNetworkPlayerLeave gets called, but the ball is already deleted by then.

Is there a way to do something to a non-persistant TNObject before it gets deleted?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Separate GameObject from parent when player leaves
« Reply #1 on: April 10, 2014, 08:14:22 AM »
Non-persistent objects are tied to the player, so when the player leaves he effectively takes all his objects with him.

The only way to do something with the object after its owner leaves is to make it persistent. You can still delete it yourself later.

djray2k

  • Jr. Member
  • **
  • Thank You
  • -Given: 4
  • -Receive: 4
  • Posts: 74
  • Blockey Hockey!
    • View Profile
    • Walking Talking Grilling Bear Studios
Re: Separate GameObject from parent when player leaves
« Reply #2 on: April 10, 2014, 09:12:33 AM »
True, I could just keep the player persistent and then delete him on the OnNetworkPlayerLeave. Thanks.