For example, when we realize that the locked door is locked with the kick animation, I want to break it with a kick, like in the Outlast game.
how can I do
if the door actor holds a flag, or enumeration for “isLocked”
then you could check against that to determine if it well “is Locked”
for a specific number of “hits” you could give it basically a health value.
then in the same place you do your check for hits on kick, you could check against the OtherActor
to see if it is a Door
then if it call something like DoDamage()
to the door.
for a situation like this I would strongly advise braking Unreal’s default behavior where “health” is a float (though I would advise/suggest that anyways because float Health NEVER makes sense)
can you make an example.I don’t know how to do it
this is a socket and line trace implementation that will work.
give the Skeletal Mesh at least 2 sockets on the foot and or leg (basically in locations based on what it means to “hit with a kick”)
give them specific names (like “S_KickStart” and “S_KickEnd”)
from your Play Montage, out of the Exec-Pin
or OnNotifyBegin()
if you are using animation notify callbacks set some variable for “is kicking” to true then out of the OnNogifyEnd()
(if applicable),OnCompleted()
and OnInterupted()
set “is kicking” to false
in tick check is Kicking
out of true grab the Mesh
and pull out Get Socket Location
with the specific name of one of those sockets as the argument. repeat for the other socket
do a line trace with those socket locations are the start and end points
out of the HitActor do IsValid()
into a Cast to your door
then either directly or by calling a function/event on the door decrease the “Health” of the door by the “Damage”
if the door Health <=0
then “break” the door.
there are other options utilizing a collider attached to a socket, or utilizing delays on a loop (though these would either need additional breaking logic, or grabbing the Length of the animation)
Can you share the video explanation?An example made with Blueprint
here is a tutorial I found https://www.youtube.com/watch?v=iPfU1SmzkkY for doing a sword, but it can be adapted to Kicking/punching (you would just be modifying the Skeletal Mesh of your Pawn/Character instead of the weapon)
What I want is how to break the door, as in the link I shared. https://www.youtube.com/watch?v=aA2pcC_e5hw Is there a sample video about this made with blueprint?
I presumed the issue was the other way around what you are looking for is “breakable” or “destructible”
the Kick doing it would be handled with detecting the appropriate source (the explanation and link I already provided)
your options for the object being destructible can be accomplished by either:
modeling the object in both a Solid form, and a broken form. this would enable you to animate the broken door specifically if you want a specific effect
or using Nanite (technically this would just make it so that you don’t have to directly model the broken form https://www.youtube.com/watch?v=DXvnjQoayQY ) this would be letting the Unreal Physics system take care of the object actually breaking.
then when the “door is destroyed” replace the unbroken object with the broken object, and playing the animation, or letting the Unreal Physics system take affect.
In the example you sent, the character breaks the object with a collision, but instead, it will break only by kicking, and the area that will be adapted to the door and determined will be broken, but will not be broken completely.
In the broken example, when it is broken, as in the example I sent, the middle part of the door is broken, but the door is not all at once, it will first check whether the door is locked, if the door is locked, the door will be broken in 2-3 moves and with each knock, the door will break a little and let’s say the door will open after the 3rd hit.
in the Character when you do your kick
trigger the line trace and determine if the hit actor is the door.
if it is the door then decrease the Health
of the Door
If you want it to then have a damaged appearance either apply a decal, swap the material/texture, or change the model to a more broken form (this can be accomplished by either storing all the meshes on the DoorActor, or by fully swapping the Actor as needed)
then when the Health
of the door is zero or less either replace the current mesh with the Broken_Door
, and play the animation, or use the Nanite fractured door to have Unreal’s physics system take care of it (this would maybe require giving the object an impulse based on the location of the Hit, normal to the point of impact which is all going to be in the Hit Data from the line trace)
I’m looking for an example video on how to do it.