Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class Collectible : MonoBehaviour
- {
- public float ros = 10f;
- public float degreesPerSecond = 15.0f;
- public float amplitude = 0.5f;
- public float frequency = 1f;
- Vector3 posOffset = new Vector3();
- Vector3 tempPos = new Vector3();
- // Start is called before the first frame update
- void Start()
- {
- posOffset = transform.position;
- }
- // Update is called once per frame
- void Update()
- {
- transform.Rotate(new Vector3(0, 30, 0) * Time.deltaTime * ros);
- tempPos = posOffset;
- tempPos.y += Mathf.Sin(Time.fixedTime * Mathf.PI * frequency) * amplitude;
- transform.position = tempPos;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement