Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by matthew_gigante · Apr 05, 2020 at 06:34 PM · unity 2dtilemaptiletilestiling

Remove a single tile from a tilemap

For starters, a weird issue I am having is that when my 3 tilemaps are set to 0 for "order in layer", my floor (dirt) map pretty much is the only art that shows, but the colliders of the wall map etc still work, so as of now the wall tilemap is set to 1 in the order so it shows up. I am trying to remove a single tile from the wall after a raycast, and want to replace it with the dirt floor after this action. The relevant code is here:

 public void Harvest()
 {
     Debug.Log("Harvest time");
     if (this.transform.localScale.x == 1)
     {
         RaycastHit2D hitInfo = Physics2D.Raycast(transform.position, transform.right, reach);
         if (hitInfo.collider != null)
         {
             currentTileMap = hitInfo.collider.gameObject.GetComponent<Tilemap>();
             Vector3 worldPoint = hitInfo.transform.position;
             Vector3Int intPosition = currentTileMap.WorldToCell(worldPoint);
             tile = currentTileMap.GetTile(intPosition);
             Debug.Log(currentTileMap);
             Debug.Log("Current tile is: " + tile);
             currentTileMap.SetTile(intPosition, null);
         }
     }

The raycast calls back that it has collided with the wall and names it in the Debug.Log("Current tile is: " + tile); but after this, it calls null and the actual tile still shows up after it is set to null.

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image matthew_gigante · Apr 05, 2020 at 06:35 PM 0
Share

-also worth noting that harvest only runs if the player hits an object with tag "Forest" for the wall, and Ignore raycast is currently set for the floor and the player to ensure the raycast hits the wall.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Durium · Feb 26 at 06:28 PM

Did you manage?

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

134 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

TileMap won't show up in 2d object in heirarchy. 0 Answers

Unity crashes when erasing tiles on a tilemap and entering those empty tiles. 0 Answers

2D tilemaps - separation of view and data, prototyping doubts 0 Answers

How to create animated tile that plays only once 0 Answers

How can I get the TileData needed to use the TileBase.GetTileData function? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges