|
Post by jrackley on Jun 9, 2017 16:09:31 GMT
very good point steak I don't know how I forgot to mention that as well,lol lack of sleep
|
|
|
Post by Strider on Jun 9, 2017 16:49:09 GMT
very good point steak I don't know how I forgot to mention that as well,lol lack of sleep Actually, it just sounds like you don't have your player prefab assigned in your vgamecontroller field. Try just going to your vGameController in your hierarchy, and you should see the field if you look at it's inspector. Make a prefab of your character, and drag it into the player field on the vGameController. Works perfectly! Thanks a lot! :D
|
|
|
Post by theblackswordsman on Jan 29, 2018 7:31:20 GMT
I'm sorry I'm a bit confused, forgive me if I sound a bit dense, I'm new to invector as well. I'm making 2.5d platformer. I have a killzone which is basically a cube with the mesh renderer turned off. It has the damage object script attached to it and vgameController script attached as well. It also has the script that was posted in this thread attached to it. I'm not sure if that's the correct thing to do though. I've placed the killzone beneath a series of platforms. If the player misses the jump he hits the killzone, dies and then respawns at the beginning of the level. But I'd like to have individual checkpoints beneath different platforms so the player doesn't have to start all the way at the beginning each time he dies. I've tried duplicating the killzone and putting a different spawn point in the vGameController field but that didn't work. I tried attaching the script jrackley created to the different killzones but that didn't work either.
I'm really not sure how to do this. If anyone can help I'd really appreciate it. Thanks so much.
|
|
|
Post by jrackley on Jan 29, 2018 13:19:47 GMT
I'm sorry I'm a bit confused, forgive me if I sound a bit dense, I'm new to invector as well. I'm making 2.5d platformer. I have a killzone which is basically a cube with the mesh renderer turned off. It has the damage object script attached to it and vgameController script attached as well. It also has the script that was posted in this thread attached to it. I'm not sure if that's the correct thing to do though. I've placed the killzone beneath a series of platforms. If the player misses the jump he hits the killzone, dies and then respawns at the beginning of the level. But I'd like to have individual checkpoints beneath different platforms so the player doesn't have to start all the way at the beginning each time he dies. I've tried duplicating the killzone and putting a different spawn point in the vGameController field but that didn't work. I tried attaching the script jrackley created to the different killzones but that didn't work either. I'm really not sure how to do this. If anyone can help I'd really appreciate it. Thanks so much. Okay there are a few issues here that I can tell by reading. I will try to list out what you need to do in your case to try and help. 1 - the vGameController should be a separate Gameobject in the hierarchy by itself, (not attached to your killzones) create an empty game object then add the vGameController script to it(assign your Player prefab from project files, not from Hierarchy). 2 - now if you want to have them spawn at checkpoints at the points you choose, then you will need to create another cube that is outside of the killzone and then turn off the mesh renderer on that cube and attach the script I provided to that cube...not the killzone. If it is attached to the killzone then the player would just spawn there and die again over and over in a loop. Let me know if this helps you out or if I did not explain it clear enough. Hope it helps.
|
|
|
Post by theblackswordsman on Jan 30, 2018 1:06:49 GMT
Thanks for responding so quickly. And also thanks for posting the script. I'm really impressed by this community.
I do have a few questions.
So I made a gameObject with the vGame Controller script attached. Then I made a cube and attached your script to it and named it: CheckPoint1. Then I dragged the CheckPoint1 object from the hierarchy into the Spawn Point field in the Game Controller game object. So now when the player dies he respawns at the place I put the CheckPoint1 box. So further down the level, I wanted to create the next checkpoint, and wasn't sure how to proceed. So I created a new game controller object and a new cube and called the new cube CheckPoint2. I dragged the CheckPoint2 box into the new game controller object's Spawn Point field and now, no matter where in the level the player dies, he always spawns at the CheckPoint2 area, which isn't what I wanted, so I must be doing something wrong.
The CheckPoint where the player spawns should be dependent upon where in the level he dies. If he misses the jump at the first series of platforms he spawns at checkpoint 1. If he misses a jump at the second group of platforms he spawns at checkpoint 2 and so on. If you could explain how I could get this accomplished it would help me a lot, and I'd really appreciate it. Also is there a way to have the level reset after the player dies? Because there are crumbling platforms in the level and if a player dies at one of them and respawns he can no longer get through the section because the crumbling platforms are gone and he can't jump far enough to get across the gaps.
Sorry for this long post and thanks in advance for your help.
|
|
|
Post by jrackley on Jan 30, 2018 3:11:11 GMT
Thanks for responding so quickly. And also thanks for posting the script. I'm really impressed by this community.
I do have a few questions.
So I made a gameObject with the vGame Controller script attached. Then I made a cube and attached your script to it and named it: CheckPoint1. Then I dragged the CheckPoint1 object from the hierarchy into the Spawn Point field in the Game Controller game object. So now when the player dies he respawns at the place I put the CheckPoint1 box. So further down the level, I wanted to create the next checkpoint, and wasn't sure how to proceed. So I created a new game controller object and a new cube and called the new cube CheckPoint2. I dragged the CheckPoint2 box into the new game controller object's Spawn Point field and now, no matter where in the level the player dies, he always spawns at the CheckPoint2 area, which isn't what I wanted, so I must be doing something wrong.
The CheckPoint where the player spawns should be dependent upon where in the level he dies. If he misses the jump at the first series of platforms he spawns at checkpoint 1. If he misses a jump at the second group of platforms he spawns at checkpoint 2 and so on. If you could explain how I could get this accomplished it would help me a lot, and I'd really appreciate it. Also is there a way to have the level reset after the player dies? Because there are crumbling platforms in the level and if a player dies at one of them and respawns he can no longer get through the section because the crumbling platforms are gone and he can't jump far enough to get across the gaps.
Sorry for this long post and thanks in advance for your help. No need to drag the checkpoints into the vGameController, they will automatically add themselves once the player reaches and triggers them. However if you have them in areas where the player will never go through them and you need them to spawn at that point then that will require some extra thought and code. Also you only want to have 1 vGameController in the scene. As for resetting the level that depends a lot on how you have it set up, you could create a script and assign the objects that you need to reset into it and then on the controller component in the onDead event in the assign the script and have it return the objects back to the original states.
|
|
|
Post by theblackswordsman on Jan 30, 2018 4:38:18 GMT
It worked. Awesome. Thanks for the help. I'll try to incorporate what you said and figure out how to reset the objects in the level. Thanks again.
|
|
|
Post by Strider on Jul 16, 2018 22:26:19 GMT
Getting some errors with the checkpoint... does this still work in the new versions?
Thanks!
|
|
|
Post by Strider on Jul 16, 2018 22:30:57 GMT
MissingReferenceException: The object of type 'GameObject' has been destroyed but you are still trying to access it. Your script should either check if it is null or you should not destroy the object.
:(
|
|
|
Post by molazsey on Mar 4, 2019 8:57:18 GMT
Is it's too late to ask some question here? i have a problem right now.I used script from Jrackley when my character dead he spawn at checkpoint but the controller is broken when i press W it's move backward A go right D go left and S go forward can someone help me please.
|
|
eldv
Junior vMember
Posts: 47
|
Post by eldv on Jul 11, 2019 21:31:08 GMT
Just found this thread and it saved me what little hair I had left! Such a simple solution. I was waaay overthinking this problem. Thank you for the solution jrackley!
|
|