I know why… sort of, but I don’t know how to fix it.
If I have gun called turret, which rotates. At the tip of the gun barrel is spawnPoint.
When the player presses Fire, I want to use a ray to check for collisions with other objects (rather than having a physical object move forwards until it hits something).
The problem arises because turret.transform.rotation (which I need to be the ray’s direction) is a quaternion. Much googling has suggested that Quaternion.eulerAngles is the very thing I need. Except when I do this I get no error, but then Debug.DrawRay(ray.origin, ray.direction * bulletRange) results in nothing being drawn. bulletRange, by the way, is 10.
If I hack the direction parameter with New Vector3(0,0,1), I get a fixed line. So it seems to me that eulerAngles is not doing what I’m being told that it does.
My code after much hacking around is a horrible mess, hence I haven’t posted any. Just wondering if anyone can give me any pointers on this.
Thanks.
[edit] Info source: convert quaternion to vector3? - Unity Engine - Unity Discussions