tilemap.worldtocell

This commit is contained in:
Vova
2023-07-12 08:22:54 +03:00
parent e39c26ed2a
commit 03cd45110d
+5 -1
View File
@@ -1,5 +1,6 @@
using System;
using UnityEngine;
using UnityEngine.Tilemaps;
public abstract class Character : MonoBehaviour
{
@@ -13,7 +14,8 @@ public abstract class Character : MonoBehaviour
protected GameObject _bonesBack;
[SerializeField]
protected GameObject _spawnPoint;
[SerializeField]
protected Tilemap _tileMap;
[SerializeField]
private LayerMask _mapLayer;
@@ -127,6 +129,8 @@ public abstract class Character : MonoBehaviour
private MapElementType GetMapElement(Vector2 direction)
{
var cell=_tileMap.WorldToCell(transform.position);
Vector2 rayStartPoint;
if (direction == Vector2.down)
rayStartPoint = new Vector2(_capsuleCollider.bounds.center.x + direction.x / 2, _capsuleCollider.bounds.min.y - 0.1f);