28 lines
529 B
C#
28 lines
529 B
C#
using System.ComponentModel;
|
|
using UnityEngine;
|
|
|
|
public class CoinScript : MonoBehaviour
|
|
{
|
|
|
|
Vector3 startposition;
|
|
|
|
void Start()
|
|
{
|
|
startposition = transform.position;
|
|
}
|
|
|
|
float a;
|
|
void Update()
|
|
{
|
|
a += Time.deltaTime;
|
|
float sinA = Mathf.Sin(a)+1;
|
|
transform.position = startposition + new Vector3(0,sinA/2f,0);
|
|
}
|
|
|
|
private void OnTriggerEnter2D(Collider2D other)
|
|
{
|
|
FindObjectOfType<GameManager>().AddCoin();
|
|
Destroy(gameObject);
|
|
}
|
|
}
|