Hi,
I recently worked my way through the Lerpz tutorial. I loved it, and was inspired. So I went on to create a new level (as suggested). I created a terrain, and then used the assets from the tutorial to create a different layout for Lerpz. All has gone well, except for one thing. The player respawns in the wrong location - not on the respawn platform.
I placed three Respawn point, named them, and set the initial respawn as the first one. But Lerpz gets dropped off to the side of my newly created layout. I added some debugger logs to the script and I can see that the proper location is actually being passed, but somehow Lerpz is ending up elsewhere.
Anyone have any idea what would be causing this? I have tried replacing the respawn points, and reconnecting everything, but I get the same result. If I manually set the player position as the location that is passed in the script, he is right where he’s supposed to be. I am running out of ideas.
If you haven’t gone through the tutorial, then I don’t think you are going to be much help. Even more of a point is that, being new to this and having just gone through the tutorial, I wouldn’t be sure what code to post. Other than adding debugger log statements, I have not changed the code at all, and it works fine in the original scene. The issue could be with the player, the respawn platform, the configurations in the inspector, the levelStatus code, the respawn code, perhaps even the terrain that I added. I certainly can’t post the entire project. But thanks for responding.
Just in case someone runs into this same issue, I figured out the cause. Lerpz is getting respawned in the right place… however, he retains his “momentum”. So, for example, when Lerpz is killed by a copper, the enemy hit knocks him off of his current position. So when he is respawned, he is still moving. In my case, he was being respawned onto a relatively small platform, so by the time he reappeared, he was off the edge. He then just fell to the ground (the terrain that I added).
I tried different methods to stop his motion as part of the death script, but I was unable to accomplish this. My hack fix was to simply add a yield (1.6) to the beginning of the death script. This gives enough time for Lerpz to come to stop again after being hit. This works well enough for my purposes here.
I, of course, plan on learning a better way to deal with this in the future, but I have plenty of things yet to learn in Unity, and for now, I can move on.