Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
0
Question by Chelmney_ · Jul 23, 2013 at 09:06 PM · raycirclearm

Rays in relation to the Distance to another point

Hey there,

I'm using a camera.ScreenPointToRay(mouse.Input) ray and I want to adjust it according to another point, the hand of an enemy. Basically, I want the end of the ray to always be reachable by the hand/the arm of the enemy. To do this, I'm calculating the length of his arm at the start of the game. Now, my question is: How do I use the length of the arm to figure out where the end of the ray should be? I'm using an IK algorithm and it requires the end point to never be out of reach. I'm having quite a hard time figuring this out here and I'm stuck. Thinking about it, I'll rephrase my question: How do I get a ray to stay on a circle with a radius of the length of an arm? It should be able to stay inside the circle, but never leave it.

Greetings,

Chelmney

Comment
Add comment · Show 3
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 robertbu · Jul 23, 2013 at 09:13 PM 0
Share

I need a drawing or screen shot to understand the question...to see the relationship of the arm to the mouse position. FYI, I found that the ray returned by ScreenPointToRay() starts at the near clip plane of the camera.

avatar image Chelmney_ · Jul 23, 2013 at 09:21 PM 0
Share

alt text

Okay, simply put: How do I move the end point back inside the circle when it leaves it like that? I know how to check when it passes the circle now, but I don't know how to check where I need to place it so it's on a line from the center of the circle to the end point but still on the edge of the circle if that makes sense.

explanation.png (4.2 kB)
avatar image robertbu · Jul 23, 2013 at 09:39 PM 0
Share

I'm still fuzzy. This is the second question today that I've struggled conceptually, so it's probably just me. I'm going to guess and make a suggestion. If you go here you will find a script with a library of 3D functions.

http://wiki.unity3d.com/index.php/3d_$$anonymous$$ath_functions

One of the functions is ProjectPointOnLine(). The 'linePoint' parameter will be your ray.origin. The 'lineVec' parameter will be ray.direction. The 'point' parameter will be the origin of the arm. It will return the closest point on the ray to the origin of the arm. If the point is greater than 'Arm Length' away, it cannot be reached. You can also use that point to calculate the closest point on the circle to the line, therefore moving it back in reach:

 pointOnCircle = (closestPoint - circleCenter).normalized * armLength + circleCenter;


0 Replies

· Add your reply
  • Sort: 

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

15 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

Related Questions

Round Slider (Circle shaped slider GUI control) 1 Answer

Lines or curves for a smooth circle in Vectrosity 2 Answers

Optimization (2D) - Box Collider vs Circle Collider 2 Answers

Vectrosity : Adding more anchor and control points 0 Answers

How could i show a color expansion from centre of circle to circumference. 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