quaternion.Euler(0,0,180) Laser Defenders issue - Enemy Shooting lecture

When I set the sprite z rotation to 180 it flips the sprite fine and fire the projectiles in the right direction.

However as soon as I change quaternion.indentity to quaternion.Euler(0,0,180) the enemy ships rotoate but not 180.

I have checked all rotations and cannot see where its getting this rotation from.

All rotations are fine until I add Euler.

Here is the code:

using System.Collections;
using System.Collections.Generic;
using Unity.Mathematics;
using UnityEngine;

public class EnemySpawner : MonoBehaviour
{
[SerializeField] List waveConfigs;
[SerializeField] float timeBetweenWaves = 0f;
[SerializeField] bool isLooping;
WaveConfigSO currentWave;

void Start()
{
    StartCoroutine(SpawnEnemyWaves());
}

public WaveConfigSO GetCurrentWave()
{
    return currentWave;
}

IEnumerator SpawnEnemyWaves()
{
    do
    {

        foreach(WaveConfigSO wave in waveConfigs)
        {
            currentWave = wave;
            for(int i = 0; i < currentWave.GetEnemyCount(); i++)
                {
                Instantiate(currentWave.GetEnemyPrefab(i),
                    currentWave.GetStartingWaypoint().position,
                    quaternion.Euler(0,0,180),
                    transform);
                yield return new WaitForSeconds(currentWave.getRandomSpawnTime());
            }
            yield return new WaitForSeconds(timeBetweenWaves);
        }
    }
    while(isLooping);      
}

}

I fixed this by using a capital q for quaternion.

Annoying as VS Code wasn’t telling me it was wrong and a lower q worked with .indentity!

Hi Beeka,

I’m glad you found and fixed the problem.

Regarding VS Code, please follow the instruction on this website and make sure all required extensions are installed: https://code.visualstudio.com/docs/other/unity.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms