Search Unity

'Collision' does not contain a definition for 'contacts'

Discussion in 'Scripting' started by jaasso, Jan 18, 2014.

  1. jaasso

    jaasso

    Joined:
    Jun 19, 2013
    Posts:
    64
    started trying out OnCollisionEnter with the example code from here http://docs.unity3d.com/Documentation/ScriptReference/Collision-contacts.html

    this piece of code

    Code (csharp):
    1.  
    2. using UnityEngine;
    3. using System.Collections;
    4.  
    5. public class qwe : MonoBehaviour
    6. {
    7.     void OnCollisionEnter(Collision asd)
    8.     {
    9.         ContactPoint zxc = asd.contacts[0];
    10.     }
    11. }
    gives this error

    error CS1061: Type `Collision' does not contain a definition for `contacts' and no extension method `contacts' of type `Collision' could be found (are you missing a using directive or an assembly reference?)

    what am i missing
     
    Last edited: Jan 19, 2014
  2. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,717
    Which version of Unity are you using?
     
  3. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Don't call your classes the same thing as Unity classes. Any time you get an error about something that's "missing", it's because you have a collision between a Unity class and your own class, and your own class doesn't have the same stuff in it. (Although if you made a contacts property for your Collision class, you wouldn't get the error, but then it still wouldn't work right.)

    --Eric
     
  4. jaasso

    jaasso

    Joined:
    Jun 19, 2013
    Posts:
    64
    4.3.2f1

    no matter what i call my class it wont recognize contacts
     
  5. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    It's not that class...you have another class elsewhere called Collision.

    --Eric
     
  6. jaasso

    jaasso

    Joined:
    Jun 19, 2013
    Posts:
    64
    ohh, thank you, thats exactly what it was