Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 Hoeloe · Aug 22, 2013 at 11:15 AM · rotationmeshtrailtransformpoint

TransformPoint gives incorrect value

Hey, so I've built a trail rendering system that's slightly more advanced than the one built into Unity, and I've created a "TrailEmitter" script, that generates trails behind it. However, I want the trails emitted to react to the rotation and scale of the emitter, so I'm calculating the new trail vertices thusly:

 verts.AddLast(par.TransformPoint(-Vector3.right * width / 2f));       
 verts.AddLast(par.TransformPoint(Vector3.right * width / 2f));

Where par is the transform of the TrailEmitter. However, I have a few TrailEmitters attached to another transform, and I'm rotating them to follow the motion of the parent object, rather than the rotation of it. However, the trails themselves seem to ignore this rotation, and use the rotation of the single parent object (though still using the correct position). I have narrowed it down to an issue with TransformPoint, which seems to totally ignore this new rotation, even though the Emitters themselves are rotated correctly, and the rotation is always done before adding new vertices to the trail. This is causing the trails to be drawn very thinly, as the vertices are put at an angle rather than straight.

This is absolutely baffling, and I really don't understand what is happening (this issue, by the way, has all occurred in a new scene, when it worked absolutely perfectly in an older one, and still does). I'm attaching a screenshot of the issue, the long vector is the direction the Emitters are facing, while the short ones are the direction the trails are actually being drawn (it should be at right angles to the longer vector).

The base code for my trail engine can be found here (though it has been modified slightly).

EDIT: After another quick experiment, it seems that as the velocity vector of the parent object approaches 90 degrees with the forward vector of the object, the rotation of the trail vertices approaches 180 degrees to the forward vector of the object. I still can't understand why this is occurring, though.

Trails are rendering at the incorrect angle

EDIT 2: I've done more tests, and found that if I use TransformDirection, it gives the correct result (but obviously doesn't take into account scale, which is necessary). This is totally baffling to me. Surely the two methods should both give a vector in the same direction?

In this image, TransformDirection gives the blue line, while TransformPoint gives the red one.

Comparing TransformPoint with TransformDirection

trailissue.png (254.2 kB)
trailerror2.png (258.9 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
0
Best Answer

Answer by Hoeloe · Aug 22, 2013 at 03:41 PM

So... I appear to have fixed this, though I'm not sure why. It seems my parent object had the X scale set to -1, rather than 1. By changing it back to a 1, it's fixed the issue, but I have no idea why that would produce this problem...

Comment
Add comment · Show 1 · 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 brikim13 · Mar 16, 2021 at 07:53 AM 0
Share

Wow that was it. For me parent's parent's... the root object's scale messed it up for me. Why is this the case? Why would InverseTransformPoint use paren't scale?

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

17 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

Related Questions

Blender Mesh rotation 3 Answers

Trail Renderer Getting Wrong Rotation 1 Answer

How can I fix a terrain hugging character so that it maintains it's original orientation, but allows rotation? 1 Answer

Let a plane follow the camera 1 Answer

When I place any model on a scene it has "-89.98" rotation by x-direction. Why it is so? 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