In the game Fortnite, there are traps that players can use to trap other players. My video above shows how you can make them in unreal engine. When a player steps on the trap, it will get triggered, and a spike will come out of it. If the player gets off of it before the spike comes out, they will be ok. Below, you can download the source code for this project and make any changes you want. This project was made in Unreal Engine 4.25. I recommend that you watch the video and try to learn how to do it, so you know how it works, and so you can make more cool stuff soon.
download link: click here
To make this, you need to first make 2 actors (right-click, press blueprint class, and select actor), 1 called spike, one called trap. For the one that is called spike, make what you want your spikes to look like (they will only be shown when someone hits the trap). You will probably want it to include multiple spikes, spread over the trap. With the spike traps, make an upside-down plane, and set it to overlap all dynamic for the collision preset. Go to the event graph, and set event begin overlap to open the level you are on with the node open level. In the trap actor, make a plane, that is the trap, and set it to overlap all dynamic as well. For this, do event begin overlap, delay for less than a second, then spawn the spike actor (do get actor location, then add some on the z-axis, I did about 10, but you might need more). do another delay, then do destroy actor for the spikes. After this, make a variable called can spawn and make it a bool. At the beginning of this graph, do a branch with the condition of can spawn. On the true branch, set can spawn to no, and then connect the rest of what we did. At the end of the code, set can spawn to yes. This should work. Watch the video above to learn more about how to create this. You might notice that the spikes show up very quickly in this example, and this is because no matter what when the spike hits you, it will kill you. You can make it so the spike shows for longer, and it does not kill you, but that is not in this example. You would need to make it so the spike only kills you for about the first .1 or .2 seconds.