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
0
Question by imtehQ · Apr 19, 2018 at 12:04 AM · unity 5

[C#] TransformPoint only works at 0,0,0 world location

This might be a bit hard to emplane, but i will try my best.

I got a gameobject This gameobject is called gameobject1, and its world location is 0,0,0 And it contains a script that has a list of points for this example the list will contain 4 points, Those 4 points are set at its local space at (-0.25, -0.25, 0) (-0.25, 0.25, 0) (0.25, -0.25, 0) (0.25, 0.25, 0)

Gameobject1 looks like this: alt text

I now make a copy of that gameobject and i call it gameobject2 And its world location is 1,0,0 it to got a list of points just like the other gameobject, it to looks like: (-0.25, -0.25, 0) (-0.25, 0.25, 0) (0.25, -0.25, 0) (0.25, 0.25, 0)

Now i want to add all the points from gameobject2, to gameobject1.

I can do that by saying somthing like:

 gameobject1.points.AddRange( gameobject2.points );

However this will result in that the gameobject2 points will be placed right on top the gameobjects1 points, its ignoring the fact that gameobject2 is not at 0,0,0 but at 1,0,0 world location.

But i can fix that by using gameobject2.transform.TransformPoint And this works just fine.

This will give me gameobject1 with all the points of gameobject1 and gameobject2. And that will look like this: alt text

But this only seems to work if gameobject1 world location is at 0,0,0. Once i change the gameobject1 location to for example 0,1,0 and gameobject2's world location to 1,1,0 The the points will be not next to it where you expect it to be but 1 extra up.

And that will look like: alt text

And at this point i have tried many things and im not one to ask questions before googling, but i think after about 3 weeks thinks about it its time to ask.

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 imtehQ · Apr 18, 2018 at 08:55 PM 0
Share

ow right, sorry if there are no spaces in the question and its all 1 big messup post, i could not find out how to do a new line :/ why enter not just work like enter works i dont know :/

avatar image Bunny83 · Apr 19, 2018 at 01:53 AM 0
Share

What's your exact code now? Since all points are given in local space you have to transform all of them into worldspace, though the points of GO1 with the transform of GO1 and the points of GO2 with the transform of GO2.

avatar image ChazBass · Apr 19, 2018 at 02:05 AM 0
Share

Please provide code to show precisely what you are doing. TransformPoint indeed does work correctly so I think the issue is that in your code what you think you are doing and what you are actually doing are perhaps not the same thing.

1 Reply

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

Answer by imtehQ · Apr 19, 2018 at 08:26 AM

I solved the issue by creating the points one by one like:

 (Gameobject2.tranform.position - Gameobject.tranform.position) + point[i]
 

This will always place the points correctly

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

160 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 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Unity UI Text - Always show 5 last lines 0 Answers

Landscape app goes portrait during app store login 0 Answers

How can I disable my player movement and camera movement when I hit I to open my inventory? 2 Answers

Can anyone tell me what is this building to the assets folder is not allowed.. 2 Answers

How can i do a Very basic enemy AI or chase system? Unity 5 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