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 juanelo · Jun 05, 2012 at 09:52 PM · vectoroffsetpointcurve

offseting a gameobject from a point, using vector direction and magnitude

alt text

Hi Guys, I feel like this should be a pretty simple thing to do, but I seem to be mixing up some things --

I've got point A on a curve. I'd like to offset this point by a fixed distance, perpendicular to the curve direction at that point, resulting in point X.

So far, what i've done is query the point directly in front of point A, point B. I then subtract point B from point A, to obtain the vector AB (or C in the diagram).

This is where I'm starting to get confused:

  • In theory, using AB.right should give me a vector perpendicular to AB, correct?

  • I now divide this vector by it's magnitude to normalize it.

  • I now multiply this vector by the scalar offset I'd like point X to have. This should give me vector D.

  • Now (really confused) the cross product of point A and vector D should give me point X?

I'd really appreciate it if anyone could point out where my mistake is, or what I should be doing differently.

Thanks, -Juanelo

Comment
Add comment · Show 2
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 Jessy · Jun 05, 2012 at 10:26 PM 0
Share

In 3D, X is a circle, not a point.

avatar image juanelo · Jun 05, 2012 at 11:04 PM 0
Share

Hi Jessy, I'm sorry, I really don't understand what that means. Could you elaborate a little?

4 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by simonmc · Jun 05, 2012 at 09:58 PM

The point where you are going wrong is using AB.right. Vector.right is just shorthand for new Vector3(1,0,0), not a vector orthogonal to the current instance.

Comment
Add comment · 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
1

Answer by Berenger · Jun 05, 2012 at 10:38 PM

You need another vector to make a plane so you can find a unique orthogonal vector (see Jessy's comment). I suggest you take Vector3.up and then use Vector3.Cross.

Comment
Add comment · 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
0

Answer by juanelo · Jun 05, 2012 at 11:03 PM

Ah, fantastic, thanks for the feedback! All along I had thought Vector3.right was local, relative to the vector's direction!

Got everything working now: alt text

Thanks, fellas.

(for those interested, this also helped a bunch: http://unity3d.com/support/documentation/Manual/ComputingNormalPerpendicularVector.html)

Comment
Add comment · 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
0

Answer by Owen-Reynolds · Jun 05, 2012 at 11:18 PM

Think you could also compute a "look" from A to B, and compute local right from there:

 Quaternion ABlook = Quaternion.LookRotation(B-A);
 Vector3 X = A + ABlook * Vector3.right * d;

It seems like not enough, but the LookRotation gives you the arrow from A to B and the line going up. That gives enough info to compute a single Right.

Comment
Add comment · 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

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

7 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Vector direction to point 1 Answer

find location on terrain when touch input 0 Answers

Move Vectors as curve towards Target 1 Answer

Move to a clicked point? 1 Answer

Get new Point from Vector and Angle 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