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 pickupPoints : MonoBehaviour
- {
- public int scoreToGive;
- private ScoreManager theScoreManager;
- private AudioSource coinSound;
- // Start is called before the first frame update
- void Start()
- {
- theScoreManager = FindObjectOfType<ScoreManager>();
- coinSound = GameObject.Find("CoinSound").GetComponent<AudioSource>();
- }
- // Update is called once per frame
- void Update()
- {
- }
- void OnTriggerEnter2D(Collider2D other)
- {
- if (other.gameObject.name == "Player")
- {
- theScoreManager.AddScore(scoreToGive);
- gameObject.SetActive(false);
- if (coinSound.isPlaying)
- {
- coinSound.Stop();
- coinSound.Play();
- }
- else
- {
- coinSound.Play();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement