29 lines
715 B
C#
29 lines
715 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;
|
|||
|
|
|||
|
private float originalY;
|
|||
|
|
|||
|
|
|||
|
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);
|
|||
|
|
|||
|
}
|
|||
|
}
|