Advertisement
Guest User

Untitled

a guest
Sep 18th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class Collectible : MonoBehaviour
  6. {
  7. public float ros = 10f;
  8.  
  9. public float degreesPerSecond = 15.0f;
  10. public float amplitude = 0.5f;
  11. public float frequency = 1f;
  12.  
  13. Vector3 posOffset = new Vector3();
  14. Vector3 tempPos = new Vector3();
  15. // Start is called before the first frame update
  16. void Start()
  17. {
  18. posOffset = transform.position;
  19. }
  20.  
  21. // Update is called once per frame
  22. void Update()
  23. {
  24. transform.Rotate(new Vector3(0, 30, 0) * Time.deltaTime * ros);
  25.  
  26. tempPos = posOffset;
  27. tempPos.y += Mathf.Sin(Time.fixedTime * Mathf.PI * frequency) * amplitude;
  28.  
  29. transform.position = tempPos;
  30.  
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement