简体   繁体   English

游戏地图中的隐形标记-Unity 2D游戏

[英]Invisible Markers in game map - Unity 2D Game

How can I place specific points on my 2D tile map that are invisible and do not obstruct any movement in the game, and when the player interacts with this it fires some code. 如何在2D瓦片地图上放置不可见且不会阻碍游戏中任何运动的特定点,并且当玩家与此交互时,它将触发一些代码。 Any help would be great, thanks! 任何帮助将是巨大的,谢谢!

Let me know if more description needed 让我知道是否需要更多说明

You probably want to use a BoxCollider2D as a trigger (ie set the IsTrigger flag to true). 您可能希望使用BoxCollider2D作为触发器(即,将IsTrigger标志设置为true)。 You can override the OnTriggerEnter2d method to fire off your code when something enters the bounds of the collider. 您可以重写OnTriggerEnter2d方法,以在某些物体进入对撞机的边界时触发代码。

Setting the IsTrigger flag will cause the collider to NOT block any actors. 设置IsTrigger标志将使对撞机不阻止任何角色。 It will simply trigger the events as the collider is entered / touched / exited etc. 当对撞机被输入/触摸/退出等时,它将仅触发事件。

See the API here 此处查看API

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM