Search Unity

Why is this script not working!!!

Discussion in 'Scripting' started by Noah-Cristino, Jun 11, 2015.

  1. Noah-Cristino

    Noah-Cristino

    Joined:
    May 25, 2015
    Posts:
    24
    Help! The error says the message has to be of type collision or it will be ignored!
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class PickingupPickups : MonoBehaviour {
    5.     public string WeaponName;
    6.     // Use this for initialization
    7.     void Start () {
    8.        
    9.     }
    10.    
    11.     // Update is called once per frame
    12.     void Update () {
    13.        
    14.     }
    15.     private void OnCollisionEnter(Collision collision) {
    16.         string namecheck = collision.gameObject.name.Substring (6);
    17.         Debug.Log (namecheck);
    18.         if (namecheck == "Pickup") {
    19.             Debug.Log("Pickup collided with!");
    20.         }
    21.     }
    22. }
     
  2. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,775
    What line does the error point to, exactly?
     
  3. LeftyRighty

    LeftyRighty

    Joined:
    Nov 2, 2012
    Posts:
    5,148
    pasted that code in and put it on a gameobject, no errors... going to need to see all the error text
     
  4. Noah-Cristino

    Noah-Cristino

    Joined:
    May 25, 2015
    Posts:
    24
  5. Noah-Cristino

    Noah-Cristino

    Joined:
    May 25, 2015
    Posts:
    24