I'm trying to make my own ABS for my game. My idea was to create a hitbox sprite at the front of the player when attacking then detect the collision from an event enemy. I suppose I have to make for every event existed they all have it's own hitbox for detection but I was wondering how are collision detection algorithms are supposed to work. It has something to do with sprite width and height or something. Any help?
collision detection?
RGSSx Script SupportFirst, a bad info for you:
no maker ever had a collision detection by default, they all work with grid coordinate comparison.
Which means that every programmer who made an ABS with pixel precise movement had to design both movement and collision from scratch.
That said, the "easy" collisions work with square hit boxes comparing the position plus the height/wide of a sprite. The more complex ones compare the transparency layer of the sprite to form a true pixel collision, but don't even try that if you don't know that.
The simplest form is to consider all squares to be defined by the four edge coordinates, and to define collision to have happened if any one of the four points from other events is inside the square defined by the four points of the player sprite.
no maker ever had a collision detection by default, they all work with grid coordinate comparison.
Which means that every programmer who made an ABS with pixel precise movement had to design both movement and collision from scratch.
That said, the "easy" collisions work with square hit boxes comparing the position plus the height/wide of a sprite. The more complex ones compare the transparency layer of the sprite to form a true pixel collision, but don't even try that if you don't know that.
The simplest form is to consider all squares to be defined by the four edge coordinates, and to define collision to have happened if any one of the four points from other events is inside the square defined by the four points of the player sprite.
Like Andar said, the default collision system in RPG Maker is grid-based position check.
For your intention, you'd have to create a collision system additionally. But it's not that hard.
Collision systems don't have necessarily something to do with sprites. It depends on what you want to achieve and what collision system you are gonna use. I advise: Axis Aligned Bounding Box or short AABB. It's one of the easiest and will be efficient for your plan.
There are tons of tutorials about AABB and collision systems in generel. Just have a look on YouTube for example:
or
2D collision detection - Game development | MDN
Algorithms to detect collision in 2D games depend on the type of shapes that can collide (e.g., Rectangle to Rectangle, Rectangle to Circle, Circle to Circle). Generally you will have a simple generic shape that covers the entity known as a "hitbox" so even though collision may not be pixel...
To sum up:
You will have to define a collision mask for every event which should be considered when attacking.
Furthermore, you just need to specify the collision mask for your attack and then check the collision mask of your attack against the collision masks of your enemy events.
Ain't collision masks literally just the same thing as making one as a sprite image then define it's coordinates and size? Or just an imaginary box?
The term "collision mask" is often used in engines where you can define a shape for an object, which will be used for collisions, in a gui. In RPG Maker, you don't have that possibility so you define it directly in your code. It's just an imaginary box, defined by variables, you don't need a sprite for that.
Original thread: https://forums.rpgmakerweb.com/threads/collision-detection.152672/