Hello Guest

Author Topic: Selecting the collision detection area on the sprite on touch.  (Read 5919 times)

RakeshChatra

  • Newbie
  • *
  • Posts: 33
    • View Profile
Selecting the collision detection area on the sprite on touch.
« on: October 10, 2013, 11:36:36 am »
How to select the particular country say USA on the world map sprite which i am using in the game. I am trying to make the area on the map highlighted when i touch on that area, using only one world map sprite.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Selecting the collision detection area on the sprite on touch.
« Reply #1 on: October 10, 2013, 11:38:09 am »
There aren't any tools to help with this specifically, assuming you want to be able to pick other countries as well. You'll have to create your colliders manually here.

RakeshChatra

  • Newbie
  • *
  • Posts: 33
    • View Profile
Re: Selecting the collision detection area on the sprite on touch.
« Reply #2 on: October 10, 2013, 11:46:33 am »
thank you unikron software for replying.. by saying colliders you mean cube or sphere colliders ?? in the world map there are around 150 countries, when i touch on each one of them only the particular area should get selected. Is there any alternate way to achieve this using raycast o something ??

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Selecting the collision detection area on the sprite on touch.
« Reply #3 on: October 10, 2013, 12:07:44 pm »
That will really depend on how you want to code this. You could I suppose, raycast, find the position / uv and work out what country you're touching. There are a lot of options, but all of them are very specific.

RakeshChatra

  • Newbie
  • *
  • Posts: 33
    • View Profile
Re: Selecting the collision detection area on the sprite on touch.
« Reply #4 on: October 10, 2013, 12:31:23 pm »
but the main problem here there are around 150 countries some of them are very small do i have to have all the 150 countries sprite in order to place them over there world map sprite to change colour when touched on particular sprite ????? gone mad over this issue please help me out..

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Selecting the collision detection area on the sprite on touch.
« Reply #5 on: October 10, 2013, 01:02:11 pm »
Wait you have to change color? You'll have to split this large texture up then, and if you were doing that you might as well define the colliders for them as well.

RakeshChatra

  • Newbie
  • *
  • Posts: 33
    • View Profile
Re: Selecting the collision detection area on the sprite on touch.
« Reply #6 on: October 10, 2013, 02:05:36 pm »
But using mesh colliders for all the small sprites would decrease the performance right..

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Selecting the collision detection area on the sprite on touch.
« Reply #7 on: October 10, 2013, 02:13:55 pm »
Not if you're just using it for this. It would be bad if they're all rigid bodies, but should be ok for raycasts.

RakeshChatra

  • Newbie
  • *
  • Posts: 33
    • View Profile
Re: Selecting the collision detection area on the sprite on touch.
« Reply #8 on: October 10, 2013, 03:15:45 pm »
using raycast is a better option or making the sprite as a button is a better option can u suggest me the best one ???

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Selecting the collision detection area on the sprite on touch.
« Reply #9 on: October 10, 2013, 03:26:28 pm »
There is no better option, it really depends on your needs and your understanding of how Unity works. Both methods work - just pick the one you're more comfortable with.