I created a death and respawn of my hero after ctrl button press. And now it’s respawning automatically. How to add respawn only after some button press (for example, R)?
Hello . There are 2 ways .
- Create boolean variable that is changing its value depending if your player is dead or not. Then add a new key event (like the one you did with the left control button) and check with branch node if the boolean variable is true or false . If its true then respawn if false do nothing.
- Use a gate node before the respawn node. Connect the R key to “open” input.
Thanks, first way worked. But I’ve got another problem. Now when I’m clicking on R, my character still can move around the world (but he has condition isdead). But when I’m clicking on R, he is spawning again. Is it possible to destroy an actor and then, when I will click R, spawn him? Ive tried to link on desytoy to seting destroy to with isDead true, but then my game mode destorying too
Ok first, at the end of the R key part you should set boolean isdead to false again so you do not spawn all the time .
(Ignore this if you already aee able to kill your player)Then if you want to destroy the player you should use get player character node and connect it to your destroy actor node . But in this case your player is going to respawn and die at the same time so you will not notice it. To notice it you should add a delay node before the destroy actor node. (Ignore until this point)
Nevertheless, if you want for example to have a result like you first press R you die then you press again R you spawn and so on, you should use flipflop node.
Feel free to ask further explanation.
Good luck!