Errors ..Unity 3D - Pick Up Item

Hi all,

    i am trying to do something like picking the coins with sound when the character collides the coin using the you tube tutorials

Unity 3D - Pick Up Item Tutorial - Part 1 - YouTube
Unity 3D - Pick Up Item Tutorial - Part 2 - YouTube

i am using the exact things and scripts that is shown in the tutorial but for me the pick up script its not working. i am getting an error saying

"Assets/Scripts/GameManager.cs(14,115): error CS1525: Unexpected symbol `PickupCount’

Here is my script

using UnityEngine;
using System.Collections;

public class Pickup : MonoBehaviour
{
public int CoinValue;
public AudioSource _audioSource;

void Awake()
{
	CoinValue =1;
	_audioSource = gameObject.GetComponent<AudioSource>();
}

// Update is called once per frame
void Update () {
	if (_triggered && !_audioSource.isPlaying)
		Destroy(gameObject);

}
void OnTriggerEnter()
{
	_triggered = true;
	
	-AudioSource.enabled = true;
	
	GameManager.PickUpCount += CoinValue;
	
	GameObject.GetComponent<MeshRenderer>().enabled = false;
	
	Instantiate(PickupParticleEffect, gameObject.transform.position, Quaternion.LookRotation(Vector3));
}

}

Can someone help me please

Regards

Suresh Jallipalli

using UnityEngine;
using System.Collections;

 public class Pickup : MonoBehaviour { 
     public int CoinValue; 
     public Audioclip clip;

     void Awake()
     {
         CoinValue = 1;
     }

     void OnTriggerEnter(Collider col)
     {
         if(col.gameObject.tag != "Player")return;
         AudioSource.PlayClipAtPoint(clip, col.transform.position);
         GameManager.PickUpCount += CoinValue;
         Instantiate(PickupParticleEffect, gameObject.transform.position, Quaternion.LookRotation(Vector3));
         Destroy(gameObject);
     }
}

What you were doing wrong:

  1. GameObject.GetComponent ->gameObject.GetComponent but not really useful here
  2. You can destroy the pick up object at the end of the collision method since you do not need it anymore.
  3. The AudioSource is removed so that you play your sound creating a new audio source
  4. That should be it.