Hi, I am working on a metroidvania prototype, for which I am using a borrowed Grid Snap method. I will paste the script at the end of the post.
I Grouped my slope tiles inside one asset, with the intention of copy-pasting it on my Scene. I am triying to figure out the best way of setting the collider ( edge / poligon / box ) in order to achive a good behaviour. Individual packs of slopes work perfectly as far as I tested.
The Problems:
While copy-pasting the packs they work perfectly for the sprites. However, I have two different problems related to the colliders:
Even though I can copy paste the sprites, the colliders seem to move chaotically, making me have to manually set the collider again.
( I am experimenting this problem with all edge, box and polygon colliders ).
I am finding it very hard to achive a clean bend while sealing the ends of my sprites. Meaning that my character gets stuck among tiles due to unaccurate coordinates ( as the end of one tile and the start of the next one are not alligned).
This is the tile grid snap script:
using UnityEngine;
using System.Collections;
[ExecuteInEditMode]
public class EditorGrid : MonoBehaviour {
public float cell_size = 1f; // = larghezza/altezza delle celle
private float x, y, z;
void Start() {
x = 0f;
y = 0f;
z = 0f;
}
void Update () {
x = Mathf.Round(transform.position.x / cell_size) * cell_size;
y = Mathf.Round(transform.position.y / cell_size) * cell_size;
z = transform.position.z;
transform.position = new Vector3(x, y, z);
}
}
I didn’t say they were so complicated, just that the Unity scene editor isn’t designed for creating tile-based games. You can do it but it’s really tedious. A tile editor is designed for tile-based games so it’s much quicker and easier to make levels. I’d recommend SpriteTile, because I wrote it, and because you can create tiles that are not bound by a uniform square grid, so you can have odd-shaped slopes as a single tile, which means no issues with polygon colliders not matching up.
Congratulations for your tool, seems pretty good, also thank you for providing this option. I will definetly use this if I get stuck.
By the way, I am happy to anounce that I found a solution to the first problem!:
I had the grid Script only in the parts of the object, but not on the sub groups. That was causing the .transform to become crazy.
Adding the grid script component to all Group, subgroups, and individual sprites makes it work perfectly
Now the current problem to solve is: How to create accurate bends among groups / tiles.
I have been adviced to have a look on this:
I am not sure how to relate it to my groups size, neither how to code it yet, I will work on it from now on until I achive the proper bend.