Instantiating mutiple prefabs using rotation of another gameObject + a gradually increaseing rotation offset
I have a gameobject (Enemy) that is in the middle of the scene and the player can move in a circle around it. This enemy is rotating constantly towards the player and what I want to do is to initiate prefabs using the enemy's Y rotation + an offset that increase for each prefab instantiated. x/z = 0
 public GameObject m_SpawnPoint;
 public Transform m_Enemy;
     void WaveAttack(float m_ProjectileAmount, int m_ProjectileType, float m_Spacing)
     {       
         for (int i = 0; i < m_ProjectileAmount; i++) {
             Instantiate(m_Projectile[m_ProjectileType], m_SpawnPoint.transform.position, Quaternion.Euler(0, m_Enemy.rotation.y + (m_Spacing * i), 0));
         }
     }
It works except that m_Enemy.rotation.y does not equal the y rotation of the enemy. If I debug it says it equals to 0.01800914 no mather the rotation of the enemy.
Anyone know what I'm doing wrong? How do I fix this? I could not find anything about this on here.
Answer by SilvanK · Aug 04, 2017 at 06:53 PM
Hey, I'm quite new to unity and I can't really answer your question, but I assume the problem is the quaternion. I have tried to work with quaternions as well and it went horribly wrong, so I tried different ways of working with rotations, and there are some.
I would suggest that you create a variable which stores the transform.rotation of the game object and use this instead of quaternions.
Quaternions aren't used much from what I have heard, because of their complexity, you would have to have a good understanding of mathematics to understand and use them correctly...
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                