Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

CS1002 expected

Discussion in 'Editor & General Support' started by emilfn03, May 25, 2020.

  1. emilfn03

    emilfn03

    Joined:
    May 25, 2020
    Posts:
    2
    I have a script and I don't know what's wrong I'm kinda new and have seen it on youtube but it seems as it works for everyone else but not me this is the script
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;

    public class water : MonoBehaviour
    {
    Transform floorlevel;
    BoxCollider c;

    void Start()
    {
    floorlevel = transform.GetChild(0)
    c = GetComponent<BoxCollider>();

    Adjustollider();
    }

    public void Adjustollider()
    {

    float waterSize = Vector3.Distance(transform.position, floorlevel.position);
    float waterCenter = waterSize / 2;

    c.size = new Vector3(c.size.x, waterSize + 0.25f, c.size.z);
    c.center = new Vector3(0, -waterCenter, 0);
    }


    }
     
  2. Lurking-Ninja

    Lurking-Ninja

    Joined:
    Jan 20, 2015
    Posts:
    10,004
    Last edited: May 25, 2020
  3. emilfn03

    emilfn03

    Joined:
    May 25, 2020
    Posts:
    2
    I have tried to do [c] but have not been working I don't see the problem nither did my friend the script it seems to work for others how tried it and a lot of people commented that it helped my no one seems to have my problem when I when others have the same problem they forgot to add ; but I haven't it just marks the c and says the error it's one of my first games I do w my friends and we do not find the problem we want the player to swim so any tips are Wellcome and have water to swim in
     
  4. Lurking-Ninja

    Lurking-Ninja

    Joined:
    Jan 20, 2015
    Posts:
    10,004
    Apparently you have problems with basic understandings. I asked you to read what I showed you to actually format your code so it will be READABLE for humans. Not a bunch of text shoved onto the screen.
    So I will do it for you, for the last time ever, because game development is not for the lazy. I know it sounds harsh, but it is true. We're not here to solve your problems, we're here to help you to solve your own problems.
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class water : MonoBehaviour
    6. {
    7. Transform floorlevel;
    8. BoxCollider c;
    9.  
    10. void Start()
    11. {
    12. floorlevel = transform.GetChild(0)
    13. c = GetComponent<BoxCollider>();
    14.  
    15. Adjustollider();
    16. }
    17.  
    18. public void Adjustollider()
    19. {
    20.  
    21. float waterSize = Vector3.Distance(transform.position, floorlevel.position);
    22. float waterCenter = waterSize / 2;
    23.  
    24. c.size = new Vector3(c.size.x, waterSize + 0.25f, c.size.z);
    25. c.center = new Vector3(0, -waterCenter, 0);
    26. }
    27.  
    28.  
    29. }
    Now, look at the 12th line in your code and tell me where do you see your semi-colon?
    Also if you would have check the actual error message you're getting, it would tell you the actual line where the error occurs.