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
2
Question by cattagames · Feb 03, 2018 at 11:12 AM · geometry

find point projection on circle around another point

Hello

alt text

-red is player position

-blue are objectives position

-orange are the points i need to find, always positioned on the black circle around the player, even if the objective point is inside of it.

How can i do it?

Thaaanks <3

immagine.jpg (17.2 kB)
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
2
Best Answer

Answer by Bunny83 · Feb 03, 2018 at 11:54 AM

Simple vector math.

Given:

 Vector3 R_Pos;
 Vector3 B_Pos;
 float circleRadius;

Solution:

 // vector from R to B
 Vector3 dir = B_Pos - R_Pos;
 
 // same direction but the length is reduced / expanded to circleRadius
 dir = dir.normalized * circleRadius;
 
 Vector3 O_Pos = R_Pos + dir;
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 cattagames · Feb 05, 2018 at 06:47 PM 0
Share

thank you very much @Bunny83 !! this was actually the first try i made, but since i have a 2D game but still have to use Vector3s, the Z-axis was the one that misleaded me. I had to set the Z axis the same on all objects in order to have it working correctly. BTW thanks again!

avatar image Bunny83 cattagames · Feb 05, 2018 at 06:58 PM 0
Share

If it's an actual 2d game (using the x-y-plane) you can simply use "Vector2"s ins$$anonymous$$d. You can directly assign a Vector3 to a Vector2 variable as they have an implicit conversion operator. This would naturally get rid of any z differences. It would also be a bit more efficient to use Vector2s as all operations on Vector2 only have to deal with 2 components ins$$anonymous$$d of 3.


Though even the problem is a 2d problem the question didn't explicitly ask for a 2d solution. 2d problems can also exist in 3d in an arbitrarily choosen plane. However if we talk about circles and points in a 2d setup we would assume that they lie in the same plane.

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

75 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

Related Questions

Convert Geolocation to 3d position 1 Answer

FPS Iron Sights Orientation of Weapon with Camera 0 Answers

Calculate a spline with start- and endpos 0 Answers

[noone knows] substitution for EdgeCollider2D.OverlapPoint ? 0 Answers

Boolean subtraction. Realtime 0 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