GameVsJam/3d Prototyp/Assets/Scripts/Utility/SpinningSpinner.cs

29 lines
714 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SpinningSpinner : MonoBehaviour
{
public float spinningSpeed = 100.0f;
public float hoverSpeed = 1.5f;
public float hoverHeight = 0.1f;
public float originalY;
void Start()
{
// Ursprüngliche Y-Position des Objekts speichern
originalY = transform.position.y;
}
// Update is called once per frame
void Update()
{
transform.Rotate(0, 0, Time.deltaTime * spinningSpeed);
float newY = originalY + (Mathf.Cos(Time.time * hoverSpeed) * hoverHeight);
transform.position = new Vector3(transform.position.x, newY, transform.position.z);
}
}