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 /
avatar image
0
Question by Alex_Edeve · Apr 08, 2019 at 03:18 PM · collision2d gamecollider2d

Collider detection in 2D

I am making a top down 2D game. There is a player, enemies, and enemies projectiles. The player can not move out of the playing area (which is a 1:1 square, the height of the camera). The enemies spawn off screen (at one of 12 predesignated spawning points) and move on screen. The enemies move in one direction and need to have distinctions between the head and body so if the player runs in to the body then they kill the enemy, and gain a point, if the player gets hit by the enemies head they get eaten and lose a point. The enemies also have projectiles, which spawn at the head, and travel in the same direction as the enemy, at a faster speed. This projectile kills the player, and they lose a point.

The problem is I don't know how to set up the colliders for this. I want the enemies and player to have a edge collider so the collision can more accurately represent the visual shape of the enemy. A capsule collider is almost the exact shape of the enemy projectile so I would like to use this. I also want a collider off screen so the enemies, and projectiles will collide with it and get removed from the game, in case the player does not kill it before it reaches the edge of the playable area.

My question is how do I make the colliders fit my use case, and how do I detect collisions threw scripts, so I can delete an instance of an object and add or subtract points from the score board.

(sorry if this is not very clear I don't really know how to explain this properly, if you need any other info please ask)

Thanks in advanced.

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Larcondos · Apr 08, 2019 at 04:36 PM

Making my best attempt here, since this is a 2D game Unity actually has specific 2D Colliders Try using some of these within your game. I also have made a 2D top down game that sounds somewhat similar I could send you if you think it would help.

Comment
Add comment · Show 1 · 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 Alex_Edeve · Apr 09, 2019 at 12:19 PM 0
Share

@Larcondos I was aware of the 2D colliders I just don't know how to utilise them properly. As far as I can tell edge colliders will not collide with other edge colliders, so I could make all the objects that need to pass threw the players boundary out of edge colliders, but then I would need two of the same colliders on the enemies, one for the head and one for the body, and I don't know how to distinguish between two of the same collider on one object in a scripts.

looking at how you did it may be helpful if you could send me that game.

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

175 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

Related Questions

Can I have two colliders attatched to my enemy that do different things and if so how?,Is it possible to have two colliders for one object 2 Answers

Alternative OnTriggerEnter2D for class instances 0 Answers

How can you change a colliders shape on collision with another collider? 1 Answer

Unity2D, OnTriggerEnter2D(Collision other){}, collision not detected, at least from what i can gather from the debug not appearing. Thanks(NEW) 1 Answer

Tilemap Collider 2D preventing objects from moving 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