- Home /
How to rotate a quad based on another object's rotation?
I'm using quad particles as decals on objects. To make them dynamic, I'm trying to rotate a quad by the same amount that the object it's "painted" on rotates (i.e. by its rotation delta). So if my object, let's call it A, rotates by 5 degrees along the x axis, my quad should do the same. I've spent today breaking my head with this problem only to realize that quad rotation is different from regular rotation.
This code works fine when rotating one object, such as a cube, based on another cube's rotation:
Quaternion rotationDelta = Quaternion.Inverse(pastRotation) * newRotation;
transform.rotation *= rotationDelta;
However, the exact same code does weird things with a quad. For example, I might be rotating object A along the y axis, and the quad performs a similar rotation along its x axis. Or the rotation occurs in several axes by totally different amounts. All the objects are independent of each other (no parenting) and I'm using world rotations for everything.
Any help would be greatly appreciated!
particles are local to their emitter. So as soon as the emitter gameobject and the cube are different in their rotations in the world, the conversion of rotations from one to the other is missing.
So you're saying there's no way to make this unity tutorial on particle decals (https://unity3d.com/learn/tutorials/topics/scripting/drawing-decals-particles) work dynamically for moving objects? It only works on static objects? And in that case, what is the suggested way of doing this? I suppose I could spawn a ton of quads as game objects and put them in various places as decals, but that seems resource intensive?
So... I've tested quad rotation with quads created directly, not as part of any particle system, and I still have the same issues, so it's not related to the emitter, this is a general quad rotation difference.
Bump... this is still an issue. I would really appreciate it if someone could help me out.
So... it's been a month and I've basically ignored this issue while working on other aspects of my game, but this hasn't been resolved. Does nobody have any insight into this? I've two spent days trying to get this to work so any help would be appreciated.