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.

14622-trailissue.png

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.

14628-trailerror2.png

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…