Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
This question was closed May 31, 2020 at 07:22 PM by chrispug for the following reason:

I was able to figure out the answer a while ago, and nobody has answered this question in almost a month, so why keep it open

avatar image
0
Question by chrispug · May 11, 2020 at 08:20 AM · tilemapdamagecirclesaoe

AOE damage on tilemaps?

Bit of a weird question, so I'll go into more detail.

I'm working on what's basically a fossil cleaning simulation, where you use various tools to break through layers of rock and clean the fossil, without damaging it too much. Each layer of the rock is its own tilemap, and each tile holds data for health and position, with classes and dictionaries. Currently, the player is able to use a drill to break singular tiles, or sections of the rock. However, due to how I set everything up, I'm not sure how to go about adding a "hammer" effect. The goal of the hammer would be to hit multiple tiles at once, in a concentric circle pattern. The innermost part of the circles would ideally deal the most damage to the layers of rock, and the outer rings would deal less damage, but are more spread out. It'd probably be best to give an example, so here's what I'm trying to simulate with this whole project. https://www.youtube.com/watch?v=ws-TA4PniJk

Currently, I have everything working except for the hammer. In a script on my Grid, the way I have the individual tiles set up is as follows:

 public Tilemap Tilemap1
 int TileHealth1
 
 tiles1 = new Dictionary<Vector3, WorldTile>();
 
         foreach (Vector3Int pos in Tilemap1.cellBounds.allPositionsWithin)
         {
             var localPlace = new Vector3Int(pos.x, pos.y, pos.z);
 
             if (!Tilemap1.HasTile(localPlace)) continue;
             var tile = new WorldTile
             {
                 LocalPlace = localPlace,
                 Layer = 1,
                 WorldLocation = Tilemap1.CellToWorld(localPlace),
                 TileBase = Tilemap1.GetTile(localPlace),
                 TilemapMember = Tilemap1,
                 Name = localPlace.x + "," + localPlace.y,
                 Health = TileHealth1 
             };
 
             tiles1.Add(tile.WorldLocation, tile);
         }

WorldTiles is the class that I take information from. For the drill script, here's a code sample.

 var tiles = GameTiles.instance.tiles1;
 
 if (Input.GetMouseButton(0))
         {
             Vector3 point = Camera.main.ScreenToWorldPoint(Input.mousePosition);
             var worldPoint = new Vector3Int(Mathf.FloorToInt(point.x), Mathf.FloorToInt(point.y), 0);
 
             if (tiles1.TryGetValue(worldPoint, out _tile))
             {
                 print("Tile " + _tile.Name + "Layer: " + _tile.Layer + "health: " + _tile.Health);
                 _tile.Health -= 1;
                 _tile.TilemapMember.SetTileFlags(_tile.LocalPlace, TileFlags.None);
 
 
                 if (_tile.Health <= 0)
                 {
                     _tile.TilemapMember.SetTile(_tile.LocalPlace, null);
                     tiles1.Remove(_tile.LocalPlace);
                 }
             }

This is repeated for every layer, with else if statements making it so the drill only hits one layer/tilemap of rock at a time.

The question now is how to implement a way to deal damage to the tilemaps in concentric circles, without starting over and setting everything up differently. I don't even know where to start on something like this, so any help is greatly appreciated. I think the tilemap method that I set up is a pretty good way to simulate fossil cleaning, but if someone has experience with damaging tilemaps in this sort of way I'd appreciate any advice I can get.

Comment
Add comment
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

0 Replies

  • Sort: 

Follow this Question

Answers Answers and Comments

129 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

Related Questions

Screen flashes red when taking damage 3 Answers

How do I simulate a tsunami wave? 6 Answers

Object Not Recieving Damage 3 Answers

Expecting ) found = 1 Answer

OnCollision Enter stopped working Please help 2 Answers


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