Perfect hitbox for Events and Player

Discussion in 'RGSS Script Requests' started by Andrea87Sky, Jun 2, 2019.

  1. Andrea87Sky

    Andrea87Sky Just a random musician/coder. Veteran

    Messages:
    81
    Likes Received:
    1
    Location:
    Sicily
    First Language:
    Italian
    Primarily Uses:
    RMXP
    Hello, i'm searching a script that makes the hitbox of characters, events, player etc fully realistic by pixel per pixel.

    I mean something like this: https://cdn.discordapp.com/attachments/404764352785285120/584401661556949002/template.png

    The idea is to having a pefect hitbox that should be the exact sprite of the character's sprite, i don't know if the game can detect when a determined point of a sprite have a color and when the sprite don't have any (empty), but i'll ask anyway.

    That will be also useful for minigames like puzzles.

    This idea is also from a game called Undertale:
     
    #1
  2. bgillisp

    bgillisp Global Moderators Global Mod

    Messages:
    12,113
    Likes Received:
    12,302
    Location:
    USA
    First Language:
    English
    Primarily Uses:
    RMVXA
    First of all, almost no game has a perfect hitbox, as the only way to do that is check every pixel the sprite takes up and see if every pixel of the object hits it. That gets really slow very fast. Even undertale (the game you reference) the hitboxes are not 100% pixel perfect, they use bounding boxes, which is the common approach as there is no other technique that is fast enough even on today's computers to detect a hitbox for every single pixel on the screen.

    If you want to see what I mean, for it to be pixel perfect a hit that only grazed the top of that heart where there is nothing shown would have to not count, and as far as I can tell it would count in undertale.

    Now, what I do think you mean is a request for a better hit box, to maybe say match a pixel movement script? That would be doable, and may already exist. But you may wish to clarify first.
     
    Last edited: Jun 2, 2019
    #2
    Heirukichi likes this.
  3. Heirukichi

    Heirukichi Veteran Veteran

    Messages:
    1,235
    Likes Received:
    492
    Location:
    Italy
    First Language:
    Italian
    Primarily Uses:
    RMVXA
    What has been said is true, however, there are pixel movement scripts that allow you to set a custom hit-box for each character (event or not). You might want to take a look at GaryCXJk free movement script. I would not label it as "perfect", but I had to write a few compatibility script for that and I have to say that it does its job.

    Of course, using pixel movement scripts that screw up the grid also means that you have to handle events movement differently. If that script does not work for you, take a look at the master script list, you might have more luck there.
    If you have no luck there either, I am afraid you should commission somebody to write it for you. I am going to be honest here: a complete movement script with hit-boxes is not exactly a trivial matter, finding somebody willing to write that for free might be hard, especially considering the amount of people who are still willing to write scripts for VX Ace.
     
    #3
  4. Andrea87Sky

    Andrea87Sky Just a random musician/coder. Veteran

    Messages:
    81
    Likes Received:
    1
    Location:
    Sicily
    First Language:
    Italian
    Primarily Uses:
    RMXP
    I know, I know, no games have a "perfect hitbox", but i wanted to ask anyway if it's possibile to do that.

    Umh yes, but i posted the post on RGSS Request Script, so I need a script for XP, not VX Ace. So sorry. :p

    And if this is the RGSS Request Script section, I hope if someone can make an hitbox system like that, maybe just modify it to make it compatible to XP, idk.
     
    #4
  5. bgillisp

    bgillisp Global Moderators Global Mod

    Messages:
    12,113
    Likes Received:
    12,302
    Location:
    USA
    First Language:
    English
    Primarily Uses:
    RMVXA
    Fair enough. Only reason I mention what I did was I once was asked to code such a thing, and even after months of work the best it ran at was 11 seconds per frame. And no, that's not a typo, it was literally 11 seconds to draw each frame on the screen, even at it's peak (granted, this was also for a 3d engine, so it might be faster on a 2d engine, but not by too much). Now with raytracing graphics cards it might be doable soon on computer IF your game uses the GPU, and XP does not use the GPU at all.

    I have no idea if someone has made a better hit box script for XP though. Maybe try a search for event collision scripts and see what comes up?
     
    #5
  6. Heirukichi

    Heirukichi Veteran Veteran

    Messages:
    1,235
    Likes Received:
    492
    Location:
    Italy
    First Language:
    Italian
    Primarily Uses:
    RMVXA
    Oh, my bad, I didn't notice the 3 at the end was missing. I don't know if there is any script with customizable hit-boxes for XP, but I am quite sure it does. XP has been around for quite a long time, and there are even pixel movement scripts that are compatible with both VX Ace and XP. Did you check the master script list? You might find a pixel movement script that has enough customization.
     
    #6
  7. Andrea87Sky

    Andrea87Sky Just a random musician/coder. Veteran

    Messages:
    81
    Likes Received:
    1
    Location:
    Sicily
    First Language:
    Italian
    Primarily Uses:
    RMXP
    I'm using right now Drago's pixel movements but it don't have hitbox customization, and i didn't found anything about scrips like these..
     
    #7
  8. Andar

    Andar Veteran Veteran

    Messages:
    28,447
    Likes Received:
    6,492
    Location:
    Germany
    First Language:
    German
    Primarily Uses:
    RMMV
    @Heirukichi
    pixel movement is a lot easier to implement than pixel collision - think ten times easier or more. Because if you check those pixel movement scripts, most of them still use the grid for event detection...

    @Andrea87Sky
    theoretically it is possible, but unfortunately I don't know anyone who has done it for XP. I know Tsukihime started one such script for Ace, but it never got beyond basic collision tests as anything else is becoming exponentially complex.

    Just think about it: a bounding box collision (especially on in a grid) only needs to trigger collision if two objects are in the same grid coordinates. That is one point to check in two coordinates.
    For a perfect collision detection, both objects would have different pixels in the 32x32 pixel area per tile. And the collision would happen if any one of these points (if it exists) is on any one other existing point of the other object. That are 32x32=1024 points to compare in two coordinates.

    A good algorithm for shape detection can reduce that a lot - but that is difficult to program in itself.

    So I suggest you look for a "Plan B" because I doubt that such a script exists. Your best chance might be to look for an ABS-Script for RMXP - games with an action battle system have the highest need for such collision checks and that might give you a chance - finding such a script as an independent script is almost unthinkable.
     
    #8
  9. Andrea87Sky

    Andrea87Sky Just a random musician/coder. Veteran

    Messages:
    81
    Likes Received:
    1
    Location:
    Sicily
    First Language:
    Italian
    Primarily Uses:
    RMXP
    Then I'll try to use only the normal rpg maker collision and drago's pixel movement. Maybe I can think about something else to do. Thanks anyway ^w^
     
    #9
  10. Heirukichi

    Heirukichi Veteran Veteran

    Messages:
    1,235
    Likes Received:
    492
    Location:
    Italy
    First Language:
    Italian
    Primarily Uses:
    RMVXA
    @Andar I know that pixel collision is much harder than pixel movement and I agree with you, it is at least ten times harder than simple pixel movement. I have been commissioned to fix the pixel collision of the script I mentioned above once because even that one used a pixel collision that was not perfect at all. However, since this is for XP, I am quite sure the said script does not work, and the same applies to my fix for it.

    @Andrea87Sky I also wrote a pixel collision script that is more or less stand-alone, but when I say "stand-alone" I mean it, in the sense that it does not apply to RGSS events at all, it applies to abstract objects that have nothing to do with events. Of course, since it is written in ruby, it can be adapted, but to be honest it is not something I am willing to do right now, not even as a commission.

    I recommend following Andar's advice and finding an ABS script, your chances of finding what you are looking for will definitely be higher that way.
     
    #10

Share This Page