Fastest Way to Check Collisions

Ask and answer questions about making games and related topics. Unrelated topics go in that other forum.

Moderators: marionline, SDHawk

Post Reply
User avatar
Gizmog
Metal King Slime
Posts: 2622
Joined: Tue Feb 19, 2008 5:41 am

Fastest Way to Check Collisions

Post by Gizmog »

I haven't even started working on anything, so this is more a hypothetical debate than anything else but: What is the fastest method of checking passability in a plotscripted game? In previous attempts, I've iterated through every maptile to generate a passability slice (A line a couple pixels wide positioned in the right way) which is parented to a passability container. When the hero tries to move, it'd generate a "feeler" and if that feeler was colliding with one of the passability slices, the move would not happen. This worked well enough without slowdown.

But I remain curious: If you're gonna have a bunch of stuff moving around, what's the fastest way? FindCollidingSlice? SliceAtPixel? Or should I quit worrying about nothing and just build the damn thing?
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

You didn't specify whether you're doing pixel-based or tile-based movement.

If you're just doing tile based movement then the easiest thing is to use check hero wall/check npc wall. It's not affects by any 'suspend' commands.

I don't think using slice collisions is going to be very much faster (and potentially a fair bit slower on a large map) than just writing the check manually using "read pass block". I can't say which would be faster. However, it might be significantly less work to use slice collision tests instead of writing the check yourself. It's definitely a pain to have to check up to 4 different tiles.

There's definitely no point worrying about speed here unless you have hundreds of things bouncing off walls.
Last edited by TMC on Sat Oct 08, 2016 5:45 am, edited 1 time in total.
User avatar
Gizmog
Metal King Slime
Posts: 2622
Joined: Tue Feb 19, 2008 5:41 am

Post by Gizmog »

Didn't specify because I wans't sure, but probably going to be pixel based. That's what I thought, thanks TMC!
Post Reply