|
Post by bender on Oct 6, 2019 18:49:54 GMT
When I climb a wall the Character moves from "DontDestroyOnLoad" into the Scene I'm playing.
Level 1 <All my stuff>
DontDestroyOnLoad Player InfoScreen
But when my character hits a wall to free climb I get
Level 1 <All my stuff> Player
DontDestroyOnLoad InfoScreen
vFreeClimb has nothing like MoveObjectToScene and I'm not using anything like that either. The best I've got is SetActiveScene. But that's been done long before.
Any ideas would be great
|
|
|
Post by bender on Oct 6, 2019 23:38:36 GMT
I just verified it with another scene. for some reason vFreeClimb is taking the player and moving it into the playing scene.
** EDIT ** Well, vFreeClimb contains the line:
transform.parent = dragInfo.collider.transform.parent; in 2 spots. This seems to be whats messing up the works. Do I need to figure out how to store off the Player or is there an alternative to this parenting?
|
|
|
Post by bender on Oct 7, 2019 1:56:58 GMT
So what I ended up having to do was... Create an empty "PlayerParent" GameObject beneath my GameController. When the scene is unloaded, I do "player.transform.parent = PlayerParent.transform" where player is the, well player.
Optionally I just added a "Parent" script to the Player:
public class Parent
{
public void Reparent()
{
transform.parent = GameManager.Instance.transform
}
}
Then attach this script to the Player and in the `OnExitClimb` callback, just have it call `Reparent()`
|
|