Quaternion RotateTowards issues

Trying to rotate the directional light. I’m pretty sure I’ve set it up the same as the documentation at Unity - Scripting API: Quaternion.RotateTowards but obviously I’m understanding something wrong. Here’s the code:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class MoveSun : MonoBehaviour {

    public GameObject scripts; //drag the gameObject that contains the clock script into here
    public GameObject sun; //drag the directional light into here

    private int currentTime;
    private int sunriseTime = 28800;
    private int sunsetTime = 57600;
    private double sunSpeed = 1.0 / 240.0;
    private float noonAngle = 13f;
    private float noonTime;
    private Quaternion sunrise = Quaternion.Euler(0, 0, 0);
    private Quaternion noon;
    private Quaternion sunset = Quaternion.Euler(0, 180, 0);
	void Start () {
        currentTime = scripts.GetComponent<Clock>().secCount;
        noon = Quaternion.Euler(noonAngle, 90, 0);
        noonTime = (sunsetTime + sunriseTime) / 2;

	void Update () {

        currentTime = scripts.GetComponent<Clock>().secCount;
        var step = sunSpeed * currentTime;

        if (currentTime >= sunriseTime && currentTime < noonTime)
            sun.transform.rotation = Quaternion.RotateTowards(sunrise, noon, (float)step);
            Debug.Log("Sun is rising!");
        else if (currentTime >= noonTime && currentTime < sunsetTime)
            sun.transform.rotation = Quaternion.RotateTowards(noon, sunset, (float)step);
            Debug.Log("Sun is setting!");

The secCount is simply timeSpeed*Time.deltaTime in another script.
The if statements are running but the sun goes to sunset at doesn’t move (the game time starts at 12pm). Or if I start before 12pm the sun jumps to noon and doesn’t move.

I think the issues are in my conditions somewhere. Just tried to use a while loop and broke Unity :frowning:

test changing the quaternion lines to this

sun.transform.rotation = Quaternion.RotateTowards( sun.transform.rotation, noon, (float)step);

unless i am missing something usnrise value is not being updated so every frame you are rotating from 0,0,0 to 0,0,180 so is always the same value.