I’m trying to make a Game Object rotate 90 degrees every 5 seconds, I thought this code would work, but the sprite just remains as it was before clicking the play button. Please, help this noob, so I can learn.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Rotate : MonoBehaviour
{
//timer support
float TotalResizeSeconds = 5;
float ElapsedResizeSeconds = 0;
//resize control
float ScaleFactorperSecond = 1;
int scaleFactorMultiplier = 90;
// Start is called before the first frame update
// Update is called once per frame
void Update()
{
Vector3 newScale = transform.eulerAngles;
newScale *= ScaleFactorperSecond*scaleFactorMultiplier * Time.deltaTime;
transform.eulerAngles = newScale;
if(ElapsedResizeSeconds >= TotalResizeSeconds)
{
ElapsedResizeSeconds = 0;
ScaleFactorperSecond = -1;
}
}
}