# good reference topic about Irregular shape Colission algorythm?

Discussion in 'Learning Ruby and RGSSx' started by nio kasgami, Oct 22, 2014.

Tags:
1. ### nio kasgamiVampCat

Messages:
8,590
2,340
Location:
First Language:
French
Hi people like the title said I would know if they exist good reference topics for Irregular shape collision algrorythm?

if you are a french script maker, I would love to link me to a french version if you are a english so link me a english version

simply because I notice my battle system I work on need some complex collision algorythm for work correctly or it will provoke bugs

thanks if people can answer my question ~

Messages:
14,476
2,869
Location:
Philippines
First Language:
Tagalog
Just look around the internet, it depends on the shapes that you want you collide... I myself just try to keep them to square (and/or rectangle) or circle coz it's simple to handle collisions between square-square, circle-circle or circle-square...

If you would do that (keeping them to squares and circles), I could give you the algorithm that I use for my proejctiles.

Last edited by a moderator: Oct 22, 2014
nio kasgami likes this.
3. ### nio kasgamiVampCat

Messages:
8,590
2,340
Location:
First Language:
French
I don't know if the square one will be enough good for handle parralax sprite (because my Battle environnement is build via parrallax)

Messages:
14,476
2,869
Location:
Philippines
First Language:
Tagalog
Depends on the general shape of each tile (like trees can be simplified to rectangles or circles), and how accurate you need it to be... If you can allow a bit of uncertainty, I'm sure you could apply squares/rectangles/circles into most objects. Warcraft III for example handles collisions via boxes, while most projectile scripts made for it (including my own) uses circles and it works just fine.

You could even break it down into multiple collision boxes/circles for large objects, though I personally haven't dabbled into that as I keep myself to small sprites.

Last edited by a moderator: Oct 22, 2014
5. ### nio kasgamiVampCat

Messages:
8,590
2,340
Location:
First Language:
French
well I don't have tiles because I use a custom battle scene so in simple the sprite are simple two layer

2nd layer ^   ^           ^   ^      *not passable*

ground ----------------------- *passable*

I only want to make second layer impassable by my character

I know for the character I can always apply a  box collision for the player but since my sprite are irregular I just want the second layer to not be passable  but I ignore wich style of collision form I need to take for this

here a exemple : ( I know eng you already saw this xD..but this is my reference in the battle system~)

Last edited by a moderator: Oct 22, 2014

Messages:
14,476
2,869
Location:
Philippines
First Language:
Tagalog
You could still just use 32x32 boxes for that, so that it's like the default tile passability on RM.

If your battle system does pixel movement and want a totally accurate system, you could make it per pixel but that would be really hard and might cost too much processing power. You could just set a nice size boxes for it to have it accurate while reducing overhead, so like 16x16 or 4x4 boxes

Basically you can use boxes that are of the same as the minimum movement of your characters/sprites/whatever... If your minimum movement is 4 pixels, then use 4x4 boxes. and so on. For the characters, you're collision box will be the same as the size of your sprite.

Handling the collision would then be easy, the hard part would be setting up the collision "map" of each possible battle scene. It would take quite a long time.

Last edited by a moderator: Oct 22, 2014
nio kasgami likes this.
7. ### nio kasgamiVampCat

Messages:
8,590
2,340
Location:
First Language:
French
well I don't think a "pixel" movement will be requires the movement of my character are similar to a tactical battle system

"the square" movement" so I think the 32x32 box seem really logics!

Messages:
14,476
2,869
Location:
Philippines
First Language:
Tagalog
Setting it up would still require quite a work though.. Good luck.

anyway, just study how the game handles the collision check on the map and you'd probably arrive at how you could check it on your battle scene

It could still be troublesome to do though, this is one of the major hurdles of custom movement scripts, how to check for collision/pathing.

Last edited by a moderator: Oct 22, 2014
nio kasgami likes this.
9. ### nio kasgamiVampCat

Messages:
8,590
2,340
Location:
First Language:
French
yeah is what I plan to do but is more now a another aspect is the Star passability in my battle system because you notice the rock in the battle arena..well I don't want them to just block the character so

I thinked to put a third layer but I am not sure if this will not provoke a lag in the battle system?

Also for the Star Passability logics I thinked about to settle the

@passability = true

and put the Z supperior to my actor

Messages:
14,476
2,869
Location:
Philippines
First Language:
Tagalog
I'd rather put the passable and unpassable blocks in the first layer since the player will always be shown above them anyways, then the star blocks on a second layer. The layering wouldn't matter on the collision/pathing checks though.

11. ### TsukihimeVeteran

Messages:
8,230
3,060
Location:
Toronto
First Language:
English
If you're using parallax maps for your battle scene why not use collision maps to specify what parts are passable or not? Then you can build your movement around it

Messages:
14,476
2,869
Location:
Philippines
First Language:
Tagalog
Will that script work on a custom battle scene?

@Nio - yeah, is that scene a new scene or you're running from inside a map?

13. ### nio kasgamiVampCat

Messages:
8,590
2,340
Location:
First Language:
French
this is totally a new scene and I don't running on a current map

@tsukihime : thanks I will study this script~

Messages:
14,476
2,869
Location:
Philippines
First Language:
Tagalog
Then I guess that won't work. Anyway, basically that would still be the end result of what you're trying to do... It's just a matter of how would you do it.

15. ### nio kasgamiVampCat

Messages:
8,590
2,340
Location:
First Language:
French
Hum I think to create a false grid for handle my movement system  and simply apply a limit to this grid

this remove the fact I need to put a complex collision script

16. ### TsukihimeVeteran

Messages:
8,230
3,060
Location:
Toronto
First Language:
English
The script simply loads an image into a table. It doesn't matter what you use it for.

I may have included example code on how to use it in the code itself but that wasn't my intention.

In fact if that is the case I'll move it into a separate script to make it clear what the collision map script is for.

Last edited by a moderator: Oct 24, 2014
17. ### AwesomeCoolBratty and spoiled little sister

Messages:
2,877
1,954
Location:
Behind you! BOOOO!
First Language:
English
Primarily Uses:
N/A
When I was attempting to do this before my team crashed I had some general ideas on how to do this (though both are not easy).

I would,

1. If it is pixel based, make it so you can enter rectangle coordinates that the player cannot pass, and be able to make as many rectangles as you want (can make a list in rectangle coordinate comments in a troop event).

2. If it is tile based, make a copy of the way vx ace itself does it.