I have a door that opens when the player steps in the trigger and closes when he leaves the trigger. The player can press ‘E’ to close the door while he is still inside the trigger. I want the player to be able to walk through the doorway when the door is opened and not be able to walk through when the door is closed…like real life. After I have the door open (in ActorBeginOverlap Event), I Set Actor Enable Collision and the target is Self (the door, this is inside the door blueprint) and this disables the collision between the door and player, so the player is able to walk through the open door. But, he is still able to walk through the door after it closes when he leaves and comes back. Problem 1: But, the player continues to be able to walk through the door regardless on whether it is open or closed.
I thought by putting Set Actor Enable Collision with New Actor Enable Collision checked, into the ActorEndOverOverlap and after the door closes that it would enable collisions but it doesn’t work. Problem 2: The door doesn’t even close at all, it always remains open and the player is unable to move through it.
So there’s two problems.
The first image is the whole open and close code for the door (the press ‘E’ isn’t pictured but it’s not important):
I am using the props Door and Doorframe in the startercontent but put the door inside the doorframe and made a blueprint class out of it. I don’t know what you mean by collision mesh, I only know what a static mesh is.
I changed the nodes to set collision enabled but then the player always walks through the door no matter whether it’s open or closed.
Changed to no collision after door opens (so can walk through open door):
Changed to enable collisions again after door is closed (I moved it from the beginning of endoverlap, which was before the door closed, to after the door closes because that makes more sense, but I tried it at the beginning too and it’s the same problem):
A collision mesh is a mesh that goes on top of the static mesh to make it collide. Static meshes do not per default have collision meshes. If you double click your static mesh, it should take you to the static mesh editor. You’ll be able to add a collision mesh in there. Use whichever simplified collision fits your static mesh the best.
Okay, thanks for telling me that but I don’t know how that’ll fix toggling of collisions. All the collision mesh editor does is allow me to turn off collisions for the door initially but that doesn’t change the fact that I don’t know how to properly disable collisions when the player overlaps with the trigger and then to enable collisions when the player leaves the trigger. I have to keep the Enable Collision checked in the editor or else my player will run straight through the door no matter what.
I figured it out but I wanted to know how to do it in blueprint not in the editor. I unchecked Enable Collision with the M_Door material and left the other material (M_Glass) alone. Then I made the actual collision box of the door be inside the door and not extending one little bit outside but left the glass parts of the door to keep its original collision box. So, I didn’t have to use any nodes at all.
Thank you for sticking with me!
If the door opens and closes you shouldn’t need to change the collisions of the door. But you basically gave yourself the answer in what you wrote, if you want to do it like that. Using the OnBeginOverlap event you can grab the static mesh (in your case, the “Door” component), then use the set collision enabled node, selecting the “no collision” option.
Similarly there is a OnEndOverlap event, to which you can again use the set collision enabled node, selecting the “collision enabled” option.
If this answered you question, please feel free to mark your question as answered (clicking the small “v” tick underneath the 0 at the answer). Thanks =)