Trouble with continuous rotation

I using the following: Unity 2020 1.17f Personal, Visual Studio, Windows 10 personal. The mesh will only move once, I have tried to move [SerializeField] in the unity GUI and then play, but nothing changes. I would like to thank you for your time and any information on this would be greatly appreciated.

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

public class Spinner : MonoBehaviour
{
[SerializeField] float xAngle = 0;
[SerializeField] float yAngle = 0;
[SerializeField] float zAngle = 0;

// Moves all transform children 10 units upwards!
void Start()
{
    transform.Rotate(xAngle, yAngle, zAngle);
}

}

//Added this because of the post on GameDev.TV chat.
public class Rotator : MonoBehaviour
{
[SerializeField] float rotationSpeed = 100.0f;

// Update is called once per frame
void Update()
{
    transform.Rotate(new Vector3(0f, rotationSpeed * Time.deltaTime, 0f));
}

}

I solve it!

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

public class Spinner : MonoBehaviour
{
[SerializeField] float xAngle = 0;
[SerializeField] float yAngle = 0;
[SerializeField] float zAngle = 0;
[SerializeField] float rotationSpeed = 100.0f;
// Moves all transform children 10 units upwards!

//  Update is called once per frame
void Update()
{
    transform.Rotate(new Vector3(0f, rotationSpeed * Time.deltaTime, 0f));
}    
void Start()
{
    transform.Rotate(xAngle, yAngle, zAngle);
}

}

I had to change some stuff around like placing the [SerializeField] float rotationSpeed = 100.0f; in the correct place aswell as the void Update().

1 Like

Good job! :slight_smile:

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

Privacy & Terms