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 Aug 31, 2018 at 09:58 AM by fr0stsp1k3 for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by fr0stsp1k3 · Aug 30, 2018 at 05:19 PM · unity 5scripting problemcollidercollider2dtilemap

Tilemap Collider 2D

So i have my sprite with rigidbody, and a collider on it - it can use my "door" portal thing fine - it can interact with other rigidbodies - and using a boxcollider 2d this works - however im trying to use tilemap collider 2d as trigger for this script - however just writing "Collider2D Col" in the constructor, does not work ? Anyone have a solution? I basically just need to know what its called, because TilemapCollider2D is not its name, nor is TileMapCollider2D - this is the error it gives me


"nterScript.cs(14,27): error CS0246: The type or namespace name TilemapCollider2D' could not be found. Are you missing UnityEngine.Tilemaps' using directive?"


Also yes, the script is ON the tilemap in question. Does anyone know the correct syntax? Or know how i can have it interact.


Here's the code

 void OnTriggerEnter2D(TilemapCollider2D col) //<--- THIS is the issue. 
                                                                  // There exists no reference to tilemap collider 2d's collision.
                                                                  // And if there does, then i need to know what it is?  Cant find it.
     {
         if (col.GetComponent<Player>())
         {
             Debug.Log("TestTileWorking?");
             
         }
     }



Edit1: - like i said to the person below, i know how tilemaps work, this specific tilemap is a child of its parent tilemap, this tilemap has enabled "isTrigger" https://imgur.com/a/O0dHKds and only contains the relevant tiles to trigger the script above- the PROBLEM, is, that the reference INSIDE THE SCRIPT - is not "TilemapCollider2D" - so then what is it? Because it isnt "Collider2D" - when i add a box2d collider i can use the script normally- but i want to very specifically use several individual tiles as encounters.

Edit2: - Still no luck, tried composite collider, with no result. Surely there must be a reference ? Obviously you'd want specific tiles on your tilemaps to have an effect?

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

2 Replies

  • Sort: 
avatar image
0
Best Answer

Answer by fr0stsp1k3 · Aug 31, 2018 at 09:57 AM

Figured it out - i hadnt checked that the tile itself had "none" instead of "sprite" collision, worked after that.

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
avatar image
0

Answer by TachyonBlast · Aug 30, 2018 at 06:29 PM

I think you are trying to use Tilemap colliders in a way they are not meant to be used. The way I understand it, Tilemap colliders are used to automtically create the collisions of the tilemap it is added to (All of the tiles will be affected). What you may be looking for is the Edge Collider 2D, which can act as a trigger and a collider.

Another solution using Tilemap collider could could be to create a child tilemap and paint there the tiles that need to trigger the script. This way every time you add a tile to this tilemap, it will already have the collider/trigger.

Comment
Add comment · Show 3 · 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
avatar image fr0stsp1k3 · Aug 30, 2018 at 07:05 PM 0
Share

Yes thats what i've already done. And i think you're wrong about that. https://imgur.com/a/O0dH$$anonymous$$ds I have a specific child tilemap which is the tiles which encounters can happen - this child encounter tilemap, are as you can see, set to be a trigger- the entire issue is that -I CAN NOT- reference it in said script. It just doesnt register, because the reference isnt "TilemapCollider2D"

avatar image TachyonBlast · Aug 30, 2018 at 07:46 PM 0
Share

Sorry, read the question wrong. According to the documentation https://docs.unity3d.com/$$anonymous$$anual/Collider2D.html Tilemap Collider is not a type of Collider 2D so i'm not sure how would you do that. $$anonymous$$aybe try to make the Tilemap Collider be used by a composite collider? That way you may be able to get the calls from the composite.

avatar image fr0stsp1k3 TachyonBlast · Aug 31, 2018 at 06:01 AM 0
Share

Just tried that, didnt work. Hmm.. When i use a normal box collider, or any custom gameobject with a box or circle collider it works fine. But i refuse to think the developers didnt think of this? I mean its such an obvious and important thing

Follow this Question

Answers Answers and Comments

254 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 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

How to destroy player when collide with enemy? 3 Answers

Detecting collision of two game objects? 0 Answers

How do I get collisions between Tilemap Collider 2d and a Kinematic Rigidbody 2d? 1 Answer

Player Gets Stuck On TilemapCollider2D 0 Answers

Tilemap collider - character passes through wall 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