Note: If you're coming here from the Tiles and Tilesets article, read on. If you found this through a search, we urge you to read the main Tiles article first.
Contents
- Introduction
- Setting the Collision Shape
- Custom Collision Shapes
- Boxes
- Polygons
Introduction
Tiles can take on more than just square shapes or blank areas. You can define their collision shapes are non-square boxes, slopes (triangles) or even arbitrary polygons.
Setting the Collision Shape
Suppose that we want to set the collision shape for the tile selected below. It's a sloped tile at about a 60 degree grade.
-
To set the collision shape, go over to the Collision Bounds window, scroll using the scroll bars to find the shape you need, and click on it.
Tip: You can edit the collision shapes for multiple tiles at a time if you select multiple tiles in the left (tiles) pane. You can do this by clicking and dragging to expand your selection rectangle.
-
Save your Tileset to confirm the changes.
Tip: If you've placed a tile inside a scene and change its collision bounds, you'll need to open that scene and save it to make the change get reflected.
Custom Collision Shapes
Sometimes you will need a custom collision shape for a tile that isn't reflected in any of the standard shapes we provide.
If this is the case, you can define a Custom Collision Shape by clicking on the + button. You can create either a Box or a Polygon.
Box Shapes
X and Y dictate the relative position of the box, in case you want it to be shifted off the origin (0,0).
All values are in percentages (0 - 100 inclusive). We do this, so that you don't have to worry about how big the tiles are.
Polygon Shapes
Create a Polygon by defining points and setting their x,y values, either through the table or through drag and drop. A polygon must have 3 or more points but no more than 12.
Note: Define points in counter-clockwise order. If you don't, the engine may crash and warn you about a polygon having negative area.
Print Article Edit Article How to Edit an ArticleGotcha: Only convex polygons are supported. Do not enter in a concave polygon such as an "L" shape. Instead, use an actor instead or split the tile into two or more separate tiles that you place on top of each other.
13 Comments
I just happened across Stencyl last night and I've had no problems with using tilesets.
You most likely did not tell your Player actor's collision group to collide with Tiles as well as Actors.
0
Same here. I'm assuming it's a bug. For the time being, I've created actors with invisible frames and set them as 'walls', placing them over the tiles and using those to provide collision. I hope this gets fixed soon, as filling the scene with actors is just going to make things unnecessarily slow.
1
This doesn't work for me I have to get each tile I want and turn them into to actors for them to have collision. I think I got a broken stencyl and it's driving me mad.
1