Freezing character after overlap
Hey so I have a system where when one player overlaps another players box collision he makes that character "it". What I am trying to do is make it so when the person tags the other person the person that has just been tagged becomes frozen for 5 seconds by adjusting the max walk speed to 0. When I try setting up a system like that it freezes both characters. What do I need to do?
asked Dec 31 '17 at 01:09 AM in Blueprint Scripting
Hey there, can you show me how are you doing the freezing part?
answered Dec 31 '17 at 02:23 AM
Based on your blueprints, I think your approach to such problems is not a good one and you will end up in a situation with lots of duplicated code and repetition! First, let's clarify the logic you're trying to implement. As I understood, your player character has a collision box somewhere nearby or around it. I'm assuming this collision box was added as a component to your character blueprint. You want to check whether another player has entered this box, and if so, you want to freeze that other player who entered the box for some pre-specified time (I don't see any delay node in your blueprints either). If this is what you're trying to achieve, then the right way of approaching such problems is for you to consider using base classes and to take advantage of inheritance and polymorphism.
Understanding these concepts will not only make your life easier but also your blueprints setup much clearer and neater! Take a look at these two answers in here and here where I briefly explain what inheritance and polymorphism are and how to use them in the questioners' problems (You can think of these questions as examples to better understand these concepts). Having understood these concepts, regardless of whether this is a multiplayer game or not, these would be steps that you need to follow:
There you go. What you wanted but in a much neater and cleaner way. Now whenever a player that was created based on MyBaseCharacter enters this box, they will freeze (for 5 sec in here). No need for casting to different players or calling functions from different places! The logic for freezing sits in this BP alone and whenever yourself or someone else want it, you will not have to trace it to multiple places just to figure out how it works.
Hope this helps.
Follow this question
Once you sign in you will be able to subscribe for any updates here