Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

1 decade ago by fulvio

I have a couple of tiles that I add to my level within Weltmeister but cannot apply a half collision box to them.

How would I go about adding something like this to the existing set of tiles?

This is the tile I'm after:

Modified Tileset

1 decade ago by Hareesun

When I've seen that I need half sized collision tiles I've simple set the tile-size to half what it is and doubled the dimensions of the collision layer. You'll need to redraw the whole collision layer, but that's pretty much the only way.

1 decade ago by fulvio

@Hareesun Any example code you can provide me? Did you have to modify any collision code in lib/weltmeister/weltmeister.js?

1 decade ago by dominic

I'd go with Hareesun's advise. If you need finer grained collisions, use a smaller tilesize for your collision layer. You don't have to modify anything in the code for this, just change the tilesize in the layer properties in Weltmeister.

If you really need half collision tiles, you could also modify the lib/impact/collision-map.js or create your collision layer with a custom tile definition. E.g. for the "half south" tile you added in the tileset image (untested):
/* Half S  */ 47: [0,H, 0,H, SOLID]

// or without the named values:
/* Half S  */ 47: [0,0.5, 0,0.5, true]

1 decade ago by fulvio

@dominic: Will give it a go, thanks.

1 decade ago by fulvio

I tried the following code, but there was no collision at all.

/* Go W  */ 45: [0,1, 0,0, NON_SOLID],
/* Half S */ 47: [0,H, 0,H, SOLID]

I then tried the following and if I spawn my player directly on top of it he jumps up and down by himself. So I'm not sure what's wrong there. Also when I debug and show collisions I don't see a border around this:

/* Half S */ 47: [0,H, 1,H, SOLID]

Will keep trying variables until I succeed, but I'm just trying to make sense of the 4 values.

1 decade ago by fulvio

Still trying to get this working. Have tried lots of combinations and nothing seems to be working as expected.

I keep getting my player shifting up and down when he's placed or jumps on the top of it. It has worked apart from this issue.

1 decade ago by StuartTresadern

If you want to do it the way Hareesun suggested I did create a simle sample for another thread: http://impactjs.com/forums/help/would-appreciate-some-thoughts-on-collision/page/1#post9580 here is the link to the download http://www.spritesheet.net/democode/impactballmaze.zip. I suppose it depends on how much work you have already put into your collision map. The sample is for a 24 x 24 base graphic tile with 8 x 8 tiles for the collision map but the idea is the same.

1 decade ago by fulvio

Will take a look, thanks.

1 decade ago by fulvio

1 decade ago by fulvio

I've posted a video of the player standing issue once his on the Half S collision tile. I can't seem to figure out why the player would be behaving this way.

Collision Bug Video

To replicate, add this to lib/impact/collision-map.js

/* Half S */ 47: [0,H, 1,H, SOLID]

Then add this updated collision tileset for WM lib/weltmeister/collisiontiles-64.png

collisiontiles-64.png

1 decade ago by StuartTresadern

The sample I posted is simple the point is you dont need to change any code. The sample shows a base graphic layer using 24 x 24 tiles in an 80 x 80 tile map. The collision layer uses 8 x 8 tiles in a 240 x 240 map. So for each of the graphic layer tiles we can layout 9 collision tiles. In your case if you have say a 16 x 16 main graphic tile in a 100 x 100 map you need to create a collision layer of 8 x 8 tiles in a 200 x 200 map. This would give you 4 collision tiles per main graphic tile which will allow you to create the half tile collisions you require.

1 decade ago by fulvio

@StuartTresadern Perfect, will give it a shot.

1 decade ago by fulvio

This works absolutely perfectly now. So for every level I just have to multiply the main width and height for the collision layer by two and divide the tilesize by two and I get to use half collision tiles.

Just wondering whether there's any impact on performance or overall level design if there's quite a complex level requiring a lot of collision tiles.

Example:

main (31x14)
tilesize: 16

collision (62x28)
tilesize: 8

1 decade ago by StuartTresadern

The simple answer is yes the more calculations that need to be performed will impact on performance. It also depends on the number of entities and how complex they are. The sizes you have given should not cause any real performance hit. Also remove any collision tiles that will never get hit, for example if it’s a ball entity it probably will never hit the corner tiles.

1 decade ago by Hareesun

As soon as you start breaking into the 1000x1000 collision tiles you may start noticing some lag, but like Stuart said, you should be fine.
Page 1 of 1
« first « previous next › last »