I'm currently making a 2D game as a beginner and someone made me a script for a spinning platform, which is stopping after a specific amount of seconds. But it has the wrong texture. It's always upside down, even if it turned one time. like on the screenshot. Besides that, two things about the platform aren't working anymore with the script he made. The rotation speed and the clockwise rotation. I will put the two different scripts below the screenshot. I hope you can understand this, feel free to ask if you have any questions.
Thanks!
script before:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Spinning_Platform : MonoBehaviour
{
private float rotZ;
public float RotationSpeed;
public bool ClockwiseRotation;
void Update()
{
if (ClockwiseRotation==false)
{
rotZ += Time.deltaTime * RotationSpeed;
}
else
{
rotZ += -Time.deltaTime * RotationSpeed;
}
transform.rotation = Quaternion.Euler(0, 0, rotZ);
}
}
script after:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Spinning_Platform : MonoBehaviour
{
public float rotZ;
public float RotationSpeed;
public bool ClockwiseRotation;
public float time = 1;
void Update()
{
time -= Time.deltaTime;
if (time <= 0)
{
rotZ += 10;
transform.rotation = Quaternion.Euler(0, 0, rotZ);
if (rotZ == 180)
{
rotZ = 0;
time = 1;
}
}
}
}