Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Getting Cell Position is not working when ContactPoint2d hits the corner

Discussion in 'Scripting' started by jherogames, Oct 1, 2018.

  1. jherogames

    jherogames

    Joined:
    Sep 5, 2018
    Posts:
    3
    Hello Guys,

    Just want to ask help below: On Picture attached, when my player hit the corner I cannot detect the position of the cell, but if it hits bottom, it able to detect the cell position. Below is snippet of my code.

    foreach (ContactPoint2D hit in other.contacts)
    {
    hitPosition.x = hit.point.x - 0.01f * hit.normal.x;
    hitPosition.y = hit.point.y - 0.01f * hit.normal.y;
    Vector3 addhit = tilemap.WorldToCell(hitPosition);
    string tileName = tilemap.GetTile(tilemap.WorldToCell(hitPosition)).name;
    tilemap.SetTile(tilemap.WorldToCell(hitPosition), null);
    }
     

    Attached Files:

    • pics.png
      pics.png
      File size:
      12.9 KB
      Views:
      645
  2. jherogames

    jherogames

    Joined:
    Sep 5, 2018
    Posts:
    3