MissingFieldException: Field 'System.Single.transform' not found.

Discussion in 'Scripting' started by sereda008, Apr 28, 2012.

  1. sereda008

    sereda008

    New Member

    Joined:
    Dec 10, 2010
    Messages:
    130
    Hallo. I am getting this error for some reason, but do not know why. What I wish to do is to rotate a door on its hinges, as though something is banging it from the other side. Here is the code which I have used:

    Code (csharp):
    1. Function Update ()
    2. {
    3. // Most other code. Things have been defined before this.
    4.  
    5. //When and how the door should move.
    6. if (MonsterIsAttacking == true)
    7. {
    8.  
    9. DoorStageCheck = DoorStage;
    10.  
    11. DoorRand = (Random.Range (0.0, 10.0));
    12. if (DoorStage == true)
    13. {
    14. //TheDoorThatMoves = DoorRand;
    15. TheDoorThatMoves.transform.Rotate(0, 0, TheDoorThatMoves,  Space.Self);
    16. DoorStage = false;
    17. }
    18.  
    19. else
    20. {
    21. TheDoorThatMoves.transform.Rotate(0, 0, -TheDoorThatMoves,  Space.Self);
    22. DoorStage = true;
    23. }
    24.  
    25. }
    26.  
    27. }


    But for some reason, this error occurs each frame:


    Any ideas?

    Edit... Actually... The more I think about it, the more an animation appears suitable... Lets see...
     
    Last edited: Apr 28, 2012
  2. Tobias J.

    Tobias J.

    New Member

    Joined:
    Feb 21, 2012
    Messages:
    423
    hm. IT doesn't tell you the line number?

    Have your assigned a gameobject to "TheDoorThatMoves"?
     
  3. sereda008

    sereda008

    New Member

    Joined:
    Dec 10, 2010
    Messages:
    130
    Hey... It appears that TheDoorThatMoves is an integer! Now this is a surprise. Lets see... Hmm... The more I think about this, the more cheap it appears... Indeed, perhaps an animation would have been better. Anyway, thanks for the help :)
     
    Last edited: Apr 28, 2012