• 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 /
This question was closed Mar 12, 2016 at 05:03 PM by Azumiar for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by Azumiar · Mar 11, 2016 at 05:10 PM · raycastnavmeshagentminimapclick to move

Setting navmesh destination by clicking on minimap

Hello, I'm currently making a MOBA type game with click-to-move.I have a minimap(Faced down camera with viewport in a corner of my screen) and i want to implement a system that when I click on minimap my player moves to that position, but currently when i click on minimap the raycast goes through the minimap and hits my terrain so the player goes there.I tried to put a UI panel at the minimaps postion to block the raycast but it seems like UI elements cant block the raycast. So any ideas how to avoid raycasting through minimap and how to move via clicking on minimap?

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

  • Sort: 
avatar image
1
Best Answer

Answer by Fydar · Mar 12, 2016 at 07:52 AM

Here is the algorithm I would use to find the location on the minimap:

  1. Ensure that the top left of the map in the world space is on the coordinate (0, 0), and if it isn't then alter the other variables to compensate for the offset.

  2. Create a system to detect if the mouse is above the minimap, and create a Boolean monitoring whether it is. Use this Bool to detect whether the ray cast should go through the map or not.

  3. When the map is clicked on map, find the distance in the x and the z-axis (Using Input.GetMousePosition()) from the top left of the minimap and multiply it by [MULTIPLYER] to get the position on the map. To calculate [MULTIPLYER], get the distance from the bottom right of the minimap and compare that to the bottom right of the world space map.

  4. Next, depending on how your game works, I would place a GameObject above the targeted position and ray cast down and receive the position and then set the target location.

I hope this helps, @Azumiar.

Comment
Add comment · Show 2 · 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 Azumiar · Mar 12, 2016 at 05:03 PM 0
Share

Thank you!I figured out how to get info about is mouse over minimap and then i just raycasted with a ray from minimap camera ins$$anonymous$$d of main camera.

avatar image Fydar · Mar 12, 2016 at 05:05 PM 0
Share

Oh, I didn't realise you had a separate minimap camera, good luck to you and I hope your project turns out well.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

47 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

Related Questions

raycast navmesh click to move 1 Answer

Physics.Raycast does not work On NotWalkable Areas Of Navmesh. 1 Answer

NavMeshAgent stop 1 Answer

Click to Move - get NavMesh Area Name 2 Answers

nav mesh agent stop ScreenPointToRay after a while 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges