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 sdgd · Oct 24, 2013 at 07:49 PM · c#localpointgeometry

geometry how to find ray local hit point?

I'm sorry but I just can't figure out but I've made it long way, ... how else to find local point with vector 3 instead of transform, ...

         Transform parent = OuterProjectile.transform.parent;
         OuterProjectile.transform.position = HitPoint;
         OuterProjectile.transform.parent = transform;
         BodyVulnerability = OuterProjectile.transform.localPosition.x;
         OuterProjectile.transform.parent = parent;

this works exactly the way I want and all that is I'm searching for that:

 BodyVulnerability = OuterProjectile.transform.localPosition.x;

information, ...

is there any else way to figure it out except with parenting, ...

sorry I'm really bad at geometry

EDIT: sorry did world position instead of local repairing the Q now, ...

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 robertbu · Oct 24, 2013 at 08:24 PM 0
Share

I'm confused about what you are doing here. 'transform.position' is a world space position. It is not the local position shown in the inspector, so changing the parent does not change this position. Put a '`Debug.Log(OuterProjectile.transform.position.x);`' above and below your parenting code. You will see the value is the same. And given what you have done, the value should be the same as HitPoint.x.

avatar image robertbu · Oct 24, 2013 at 08:26 PM 1
Share

If you are looking for the local position (which this code does not do), you can use Transform.InverseTransformPoint().

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by jonnyhopper · Oct 24, 2013 at 08:24 PM

Hi!

Don't worry, this stuff can be confusing. I'm presuming you want the result local to whatever GameObject you're currently "in" - i.e. whatever holds transform. I think you should be able to do something like:

 Vector3 local_point = transform.worldToLocalMatrix.MultiplyPoint3x4(  Hitpoint );

Hope that helps J.

Comment
Add comment · Show 6 · 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 sdgd · Oct 24, 2013 at 08:30 PM 0
Share

can you explain the code a bit please?

and you are presu$$anonymous$$g me correctly :)

avatar image jonnyhopper · Oct 24, 2013 at 08:35 PM 0
Share

sorry, typo on my code. it should be $$anonymous$$ultiplyPoint3x4

avatar image sdgd · Oct 24, 2013 at 08:52 PM 0
Share

both codes work fine :) thanks to both but kinda I like more the not matrix, ...

 BodyVulnerability = transform.InverseTransformPoint( HitPoint ).x;
 BodyVulnerability = transform.worldToLocal$$anonymous$$atrix.$$anonymous$$ultiplyPoint3x4( HitPoint ).x;

may I ask what's the difference? they both work as I wanted, ...

avatar image jonnyhopper · Oct 24, 2013 at 08:53 PM 1
Share

You're right - InverseTransformPoint is a helper function to do exactly the same thing. Use that!

avatar image jonnyhopper · Oct 24, 2013 at 09:10 PM 1
Share

It's for convenience. It was added in Unity to mean you don't need to type worldToLocal$$anonymous$$atrix.$$anonymous$$ultiplyPoint3x4 etc - but its functionality is the same.

Show more comments

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

16 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

Related Questions

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

How to check if point is inside collider? 1 Answer

After I initially add score it keeps adding. 2 Answers

Convert 3D model to point cloud - possible? 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