going_balls/Assets/Scripts/CoinScript.cs

27 lines
576 B
C#

using UnityEngine;
public class CoinScript : MonoBehaviour
{
public GameManager gameManager;
public Vector3 RotatingSpeed;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
}
// Update is called once per frame
void Update()
{
transform.Rotate(RotatingSpeed * Time.deltaTime * 5f);
}
void OnTriggerEnter(Collider other)
{
if(other.tag=="Ball")
{
Destroy(gameObject);
gameManager.AddCoins();
}
}
}