Home > other >  TileMap. WorldToCell obtain corresponding Tile is not accurate
TileMap. WorldToCell obtain corresponding Tile is not accurate

Time:09-27


Tilemap starts to get to ContactPoint, then through WorldToCell obtain corresponding TILE position, but the same ContactPoint return of TILE position is different,
Which is the same the world coordinates to TILE location will be different,,

Or are there other solutions can obtain Tilemap starts the corresponding TILE,

 
Void OnCollisionEnter2D Collision2D (other)
{
Tilemap _tileMap=other. GameObject. GetComponent (a);

Int contactCount=other. ContactCount;
ContactPoint2D contacts []=new ContactPoint2D [contactCount];
Other. GetContacts (contacts);
For (int I=0; i {
Vector3Int tile=_tileMap. WorldToCell (contacts [I] point);

_tileMap. SetTile (tile, null);

The Debug Log (ContactPoint "with" + contacts [I] point);
The Debug Log (" TilePos with "+ tile);
}
Destroy (gameObject);
}



CodePudding user response:

Camera. The main. ScreenPointToRay (Input. MousePosition). GetPoint ()
  • Related