Remove part of hitbox

177 views
Skip to first unread message

Emanuele

unread,
Nov 13, 2015, 5:51:09 AM11/13/15
to HaxeFlixel
I'm writing a dungeon crawler game where every room is delimited by four walls, wich I'm colliding with the player with the FlxG.collide function.

Now I'm trying to add doors in the middle of the walls, but the collision with the walls obviously prevents the player from moving trough them.

Is there any easy way to remove part of the hitbox or do I have to write my own collision code?

And I can't just remove the middle part of the walls sprites, since it's not sure that there will be a door on each wall.

Lemur Motion

unread,
Nov 13, 2015, 1:18:12 PM11/13/15
to HaxeFlixel
Is you dungeon built with tiles? If it is you can turn of collision for the door-tiles. 
If its not built with tiles you should maybe consider doing that instead, it's great for dungeon crawlers, platformers etc. 

Eric Grice

unread,
Nov 13, 2015, 2:32:05 PM11/13/15
to haxef...@googlegroups.com

I second this.  Tiles are the way to go for this kind of game, plus they are more efficient than using big images.  It's easy to get set up if you follow the tutorial on HaxeFlixel website.  And you can use ogmo editor or something similar to design levels.

--
HaxeFlixel Development Community
See our github https://github.com/haxeflixel/ and our documentation http://haxeflixel.com/documentation/
---
You received this message because you are subscribed to the Google Groups "HaxeFlixel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to haxeflixel+...@googlegroups.com.
Visit this group at http://groups.google.com/group/haxeflixel.
To view this discussion on the web visit https://groups.google.com/d/msgid/haxeflixel/ad0c6972-fa9b-45af-92e9-396aa627b5cc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jeru Sanders

unread,
Nov 13, 2015, 5:54:49 PM11/13/15
to HaxeFlixel
To be noted you can change the size of the hitbox with the .width and .height property, and you can adjust it's offset with the .offset property.

MegaLeon

unread,
Nov 14, 2015, 8:41:26 AM11/14/15
to HaxeFlixel
Take a look at this dungeon generator too: http://leongotgame.blogspot.co.uk/2015/08/haxeflixel-random-dungeon-generator.html

Trick is to not have walls where you want your door.

Emanuele

unread,
Nov 14, 2015, 11:49:06 AM11/14/15
to HaxeFlixel
No, it's not a tile based game, neither can I use tilemaps because all the assets I've got for the walls, floors, etc. don't repeat.
I'm not sure if I could just use a tilemap for collisions and keep all the assets the way they are now, but it doesn't seem like a really good way to do it.

Michael Zehnich

unread,
Nov 14, 2015, 12:34:51 PM11/14/15
to HaxeFlixel
For my player in a paltformer I'm working on, I've got his regular hitbox for colliding against walls and the world, and I have a second FlxObject in the player class for his "combat hitbox" which is much smaller. Kind of like how SHMUPs do it.

I guess you could do it this way too, I mean this kind of depends on how you're setting up your levels and stuff, but if doors are like a child of walls then maybe you could have some AddDoor() function that "splits" the walls "hitboxes" up (basicaly change the width/height of the wall as another poster said, and add FlxObjects with the same collision settings to fill in any gaps). Kind of weird but that's one way of making it work at least

I'm not sure of any functionality to allow some kind of "portal", or in 3D level design terms, "CSG subtract"/boolean drill a hole through a FlxObject's collision bounds...

Oh, that gives me an idea actually, you could just set the entire wall to overlap with the player and do your own collision resolution handling. Overlap wall and player with a callback function, and in the callback see if player is overlapping the wall, call a collide(wall, player) and that should act as if he collided with the wall (and put him back where he was, not letting him pass). But if the player is overlapping a door as well then don't do this, and just let him pass.

(sorry for the rambling post but figured it could give some more ideas :))

Emanuele

unread,
Nov 14, 2015, 1:25:50 PM11/14/15
to HaxeFlixel
Yep, your second suggestion worked just fine.

Great idea, thank you!
Reply all
Reply to author
Forward
0 new messages