void Update() { if (teamColourRenderer != null) { teamColourRenderer.material.SetColor("_TeamColor", Utility.TeamColour(team)); } transform.localPosition = new Vector3((float)position.y, transform.localPosition.y, (float)position.x); transform.localRotation = Quaternion.AngleAxis((float)DReal.Degrees(rotation), Vector3.up); }
void OnDrawGizmosSelected() { Gizmos.color = Color.red; Gizmos.DrawWireSphere(transform.position, (float)attackRange); // Projectile spawn location & stuff. Gizmos.color = Color.red; Vector3 turretPosition = new Vector3((float)turretAttachPoint.x, 0, (float)turretAttachPoint.y); Matrix4x4 rotationMatrix = Matrix4x4.TRS(transform.position, transform.rotation, transform.lossyScale) * Matrix4x4.TRS(turretPosition, Quaternion.AngleAxis((float)DReal.Degrees(turretRotation), Vector3.up), transform.lossyScale); Gizmos.matrix = rotationMatrix; Gizmos.DrawWireSphere(new Vector3(0,0,0), 0.5f); Gizmos.DrawWireCube(new Vector3(0, 0, (float)projectileSpawnDistance), new Vector3(0.5f, 0.5f, 0.5f)); }
void Update() { // Always update local rotation. // Touching the world rotation causes fighting with Entity. turretMesh.transform.localRotation = Quaternion.AngleAxis((float)DReal.Degrees(turretRotation), Vector3.up); }