英文:
How to detect if all edge points of a 2D sprite are touched?
问题
我正在尝试检测玩家是否触摸了2D精灵的所有边缘点(触摸输入触摸),如果是这样,就增加一个点。该形状是带有多边形碰撞器的2D精灵。
我还在形状的顶部绘制了一条线渲染器,该线与多边形碰撞器的触摸相碰,用作玩家的指示器。
作为一名初学者,我一直在为此而努力。我该如何实现这一目标?任何帮助将不胜感激。
编辑:
遵循willow的方法:
英文:
I am trying to detect if the player has touched (touch input touch) all the edge points of a 2D sprite, and if so, increment a point. The shape is a 2D sprite with a polygon collider.
I am also drawing a line renderer on top of the shape where the touch collides with the polygon collider. To serve as an indicator for the player.
As a beginner, I have been struggling with this a lot. How can I achieve this? Any help would be greatly appreciated.
Edit:
Following willow's approach:
答案1
得分: 1
There is one easy way ( without so much mathematics ) is to add Rigidbody2D/Collider2D around your circles, then you check if the player touch them in order. every small rectangle is a Rigidbody2D/Collider2D, so you raycast, if it hits, add it to an array. when touch finishes, check if all rectangles have been touches in order with a For loop 1,2,3,4,5,6. the more rigidbodies you have, the more accurate you are.
英文:
There is one easy way ( without so much mathematics ) is to add Rigidbody2d/Collider2d around your circles, then you check if the player touch them in order. every small rectangle is a Rigidbody2d/Collider2d, so you raycast , if it hits, add it to an array. when touch finishes, check if all rectangles have been touches in order with a For loop 1,2,3,4,5,6. the more rigidbodies you have, the more accurate you are.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论