Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When I first started to develop in Unity I followed the Unity Tutorial for the Space Shooter 2D game and used the knowledge from that to create something myself. Looking at it now it may not have been the best idea.

Currently my game is 2D but in a 3D environment where the camera is top down and I am trying to figure out how I can detect a collision between a UI Image and my Player GameObject.

Any help will be extremely appreciated!

share|improve this question
    
Can you please elaborate what you want to do. It would be helpful to answer. For example if you want to shoot the enemy while touching on them, then you can use Raycast. – Shuvro Sarkar Aug 17 at 20:16

Two ways to go about this:

  1. Use regular (3D) colliders for everything.
  2. Use 2D colliders for everything.

It doesn't particularly matter which you pick, although working with 2D colliders will create fewer potential problems if you don't plan to use that extra axis of movement. Your main problem right now seems to be picking one or the other physics model.

Generally, if you're using an image as a game element it isn't part of the UI. You would normally use a sprite instead. But, if your heart is set on using a UI image, you could match a collider's position and shape to it in the place where it appears to be. Or, you could move the world in line with the UI (assuming you're using the new Unity UI, not the old IMHUI). Really though, it will make more sense to use a sprite.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.