Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
This question was closed Jan 26, 2016 at 06:31 PM by redrob5 for the following reason:

Problem is not reproducible or outdated

avatar image
0
Question by redrob5 · Jan 26, 2016 at 12:06 PM · animationscripting problem

Why does this extremely simple script return an error?

I am beginning to try and learn programming and someone suggested i use this code so that an animation plays when i make my character run. It returns this single error in unity: "Assets/Scripts/Run.cs(1,10): error CS0116: A namespace can only contain types and namespace declarations" - How can i fix this?

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image gjf · Jan 26, 2016 at 12:22 AM 0
Share

if you're aksing for help with script errors, please include the script ;)

don't forget to format it using the 101/010 button

avatar image redrob5 gjf · Jan 26, 2016 at 05:06 PM 0
Share

Cant believe i forgot to add my script, thanks for pointing that out!

1 Reply

  • Sort: 
avatar image
2

Answer by phil_me_up · Jan 26, 2016 at 01:42 PM

As gjf said, please include your script when asking these questions.

However, my guess based on the error message (indicating the error is on line 1) is that you're doing something like this:

 int test = 0;
 using UnityEngine;
 using System.Collections.Generic;
 
 public class MyClass : MonoBehaviour 
 {
 }

Note that you are declaring an int outside of the class which is not permitted. Instead do this:

 using UnityEngine;
 using System.Collections.Generic;
     
 public class MyClass : MonoBehaviour 
 {
     int test = 0;
 }

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image redrob5 · Jan 26, 2016 at 05:05 PM 0
Share

Wow, i completely forgot to add that, I feel so dumb! Thanks for the reply!

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Controlling animation with IsTouchingLayers doesn't work on moving platform. 0 Answers

Change walking anim if gun is picked up? 1 Answer

How can i use the Animator in script to find when animation clip finished playing and then stopping the animation ? 1 Answer

How can I use IK with AnimationClipPlayable or AnimationMixerPlayable? 1 Answer

How do I stop moving when attacking? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges