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 /
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 $$anonymous$$imap and then i just raycasted with a ray from $$anonymous$$imap 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 $$anonymous$$imap camera, good luck to you and I hope your project turns out well.

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

NavMeshAgent stop 1 Answer

nav mesh agent stop ScreenPointToRay after a while 0 Answers

Enemy freezes in NavMesh and starts attacking? [Duplicate] 0 Answers

Moving cubes into a grid formation 1 Answer


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