2024-04-05 14:08:45 +02:00
|
|
|
|
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;
|
|
|
|
|
|
2024-04-06 18:30:26 +02:00
|
|
|
|
public float originalY;
|
2024-04-05 14:08:45 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Start()
|
|
|
|
|
{
|
|
|
|
|
// Urspr<70>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);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|