PickupMotion.cs 544 B

1234567891011121314151617181920212223
  1. using UnityEngine;
  2. namespace DunGen.Demo
  3. {
  4. public class PickupMotion : MonoBehaviour
  5. {
  6. public float SpinSpeed = 90;
  7. public float BobSpeed = 1;
  8. public float BobDistance = 1;
  9. private Vector3 positionOffset;
  10. protected virtual void Update()
  11. {
  12. transform.position -= positionOffset;
  13. positionOffset = transform.up * Mathf.Sin(Time.time * BobSpeed) * BobDistance;
  14. transform.position += positionOffset;
  15. transform.rotation *= Quaternion.AngleAxis(SpinSpeed * Time.deltaTime, transform.up);
  16. }
  17. }
  18. }