How I Implemented Melee Hit Detection in Unreal Engine

แชร์
ฝัง
  • เผยแพร่เมื่อ 23 ธ.ค. 2024

ความคิดเห็น • 19

  • @EcksDeeGaming
    @EcksDeeGaming หลายเดือนก่อน +1

    Love this solution! I've been meaning to find a nice solution for filling in the gaps between traces. Previously I've been taught a way that stores the current vector point per tick to then use it as the Start/End point for the next loop cycle. But that only really worked well if you had 1 single point. With a Weapon skeletal mesh with 2 vector points, I think this is a really optimal solution. Thanks for showing it off!

    • @peanut_games
      @peanut_games  หลายเดือนก่อน

      Nice, thanks for watching. In my latest iteration I have it all inside a macro so it doesn't even require variables in the typical sense. I started a video on how to do it but realized it's more convoluted than I thought lol, I still plan on it but I need to figure out how to break it into palatable sections.

    • @Risha-ki1xz
      @Risha-ki1xz 10 วันที่ผ่านมา

      @@peanut_games Any ETA on that video, I think it would help me out a lot, trying to make a good and efficient melee damage trace is so hard 🥹

    • @peanut_games
      @peanut_games  9 วันที่ผ่านมา +1

      ​@@Risha-ki1xz Yeah I just always have a lot going on somehow 😵 I do need a new video so I think I will do that next. So hopefully by the end of the week

    • @Risha-ki1xz
      @Risha-ki1xz 9 วันที่ผ่านมา

      @@peanut_games Awesome, looking forward to it!!

  • @turritom
    @turritom 8 หลายเดือนก่อน +1

    ok i have to take a closer look at this, because i have exactly this problem that when i hit fast with my weapon it sometimes doesn't hit the opponent ..in my melee combat game.

    • @peanut_games
      @peanut_games  8 หลายเดือนก่อน +1

      indeed, the joys of developing for PC with widely variable framerate

    • @SharkTankOP
      @SharkTankOP 5 หลายเดือนก่อน

      just get a better pc if u have low fps what a skill isue

  • @image4546
    @image4546 11 หลายเดือนก่อน +1

    Hello, can you make more detailed tutorial how exactly it can be implemented maybe to clean project?

  • @Dnf_Jeff
    @Dnf_Jeff 7 หลายเดือนก่อน

    Wonder if instead of that tick thing you did, if you could make it a function and call a set timer by function name, set looping, and that nodes “time” (float- time in seconds) (for this something close to 1 should give a similar, potentially more light weight option) input is (time to wait between each loop) creating your own “tick” at whatever rate (time) and it doesn’t run off the actual tick. In this situation the function would only loop during the attack, so something needs to stop that “set timer by function name”

    • @peanut_games
      @peanut_games  7 หลายเดือนก่อน

      It runs off the animation notify event so it's not being executed unless the attack animation is playing and within that, during the 1-2 second window of the event. It gets destroyed when it finishes. You definitely want it executing every tick and more, unless you're never dropping below 120 fps. As a FYI you can always modify tick interval for actors too if you need to.

    • @Dnf_Jeff
      @Dnf_Jeff 7 หลายเดือนก่อน

      @@peanut_games whoa tick interval for an individual actor.
      I’m working on a harvesting system and I just want swings to stop when they hit something. Axe hit tree.
      I’m currently working on a harvesting system that works with these new PCG foliage systems. By making a data table with rows matching display names of the various static mesh’s used in PCG. You can associate “hit component”-“cast to hierarchicalinstancedstaticmesh”- “get static mesh”’s display name with the data table where you can house info about what it is, what it gives, etc. It’s useful because PCG uses HISM which is a collection of instancedstaticmesh’s with corresponding index. In the level the trees are individually “dumb” but by passing this data back I can then decide how the player should react.
      Just a little bonus for responding quick.

    • @peanut_games
      @peanut_games  6 หลายเดือนก่อน +1

      YT didn't notify me, I guess because the @ got bugged. So for that I'd still start from the animation but probably reference back to a "start attack" event which loops itself, and an end attack event that can be executed when you hit a valid harvestable object. Use looping nodes with a delay and a Gate node, the stop event closes the gate. Either that or play a new animation and it will cancel the event tied to the first animation, provided it only runs on tick.

  • @davidcobosgomez2921
    @davidcobosgomez2921 4 หลายเดือนก่อน

    This working in the server?

  • @RDD87z
    @RDD87z ปีที่แล้ว

    theres something i didnt quite understand.. so if u take the hitdetections that are betwen current and previous frame, u still can hit on the previous traces even if the current frame has already been played?
    meaning from A(blue) to B(Blue) there are 5 pink spheretraces... are they still giving damage even if the sword is maybe already at B or C frame?
    what i mean is. .if it needs a and b to calculate the inbetweens.. it means it should also hit even if the current frame is already B . is it like that?
    also i think u should make so the endpoint of the pink ones are the same length the blue ones have., blue will always be the same length so maybe u should take the vectorsize to consider having the same hit radius everytime? Im learning so i dont know if im saying some insane stuff :D
    good job ill need this for my game too!

    • @peanut_games
      @peanut_games  ปีที่แล้ว

      It uses a vector variable to store the current frame's endpoint, which is saved until the next frame, hence it becomes 'last endpoint' by the time it's actually accessed. It's updated at the end of the frame and zeroed at the end of the whole attack event. In this case the start point is always the eyes so I don't need to store that. Beyond that it works kind of like a shotgun would, but instead of math to simulate a radial spread it's just math to interpret evenly between two points. As for damage, it just uses the exact same function for the 'natural' hit detections. It will hit and cause damage to an enemy one by one as each interpretation is made, just as it would normally but this all happens within a fraction of a second on the *later* frame.
      You're right about lengths but don't worry I've also got a souls-like template asset coming, currently on hold to yeet this game out, and I've optimized the consistency and lengths to perfection. I spent a lot of time on it as it matters much more for the souls-like genre. I'll probably talk about that method later. I will say this way is simpler lol. 15 fps is a pretty extreme example with huge gaps too, anyone running normal fps, even 30, wouldn't really be affected. Not really worth the delay to overhaul it in this case.
      Thanks for watching and commenting 🙂

  • @edgardsimon9623
    @edgardsimon9623 ปีที่แล้ว

    do u think it work with something similar for dark and darker ?

    • @peanut_games
      @peanut_games  ปีที่แล้ว

      Pretty much every game will use something like this, even shooters, but for guns the traces are basically infinite in length. It's harder to say if other games adjust for framerate like I did though.

    • @edgardsimon9623
      @edgardsimon9623 ปีที่แล้ว

      @@peanut_games ty