• 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 post has been wikified, any user with enough reputation can edit it.
avatar image
-2
Question by X_rploader Boss · Dec 31, 2014 at 05:01 PM · c#parsingparsing error

i am pretty sure that this is right but.....

the problems are (5,9)CS1519 and (11,9)CS1525

code:

  using UnityEngine;
 using System.Collections;
 public class Skellyattack : MonoBehaviour {
 public GameObject player;
 public GameObject skelly;
 public float distance;
 // Use this for initialization
 void Start () {
 }
 // Update is called once per frame
 void Update () {
 player = GameObject.find ("Player");
 skelly = GameObject.Find ("skeleton");
 distance = Vector3.Distance(player.transform.position. skelly.transform.postion);
 if (distance <= 3) {
 skelly.animation.CrossFadeQueued("run", 0.3f, QueueMode.PlayNow);
 }
 else if(distance < 15 && Distance > 5.0f){
 skelly.animation.CrossFadeQueued("attack", 0.3f. QueueMode.PlayNow);
 skelly.animation.CrossFade("run");
 skelly.transform.LookAt(player.transform.position);
 skelly.transform.postion = Vector3.MoveTowards(skelly.transform.postion, player.transform.position);
 }
 else
 {
 skelly.CrossFadeQueued("run", 0.3f, QueueMode.PlayNow);
 skelly.CrossFade("idle");
 }
 }
 }

Comment
Add comment
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

2 Replies

· Add your reply
  • Sort: 
avatar image
3

Answer by Eric5h5 · Jan 01, 2015 at 06:08 PM

Pro tip: when Unity gives you an error message, Unity is correct and you are wrong.

Comment
Add comment · 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
0

Answer by RudyTheDev · Dec 31, 2014 at 05:03 PM

You really need to be able to debug and solve syntax errors yourself if you want to learn game development properly. Otherwise, you will get stuck a lot. The errors here are very obvious (besides MoveTowards speed). You should also be posting the full error message and explaining the steps you have taken to solve it yourself. Most of these errors have been answered many, many time before, if you do a quick search beforehand. And do try to format your code properly. Anyway:

 using UnityEngine;
 using System.Collections;
 
 public class Skellyattack : MonoBehaviour
 {
     public GameObject player;
     public GameObject skelly;
     public float distance;
     public float speed;
 
     // Use this for initialization
     void Start()
     {
 
     }

     // Update is called once per frame
     void Update()
     {
         player = GameObject.Find("Player");
         skelly = GameObject.Find("skeleton");
         distance = Vector3.Distance(player.transform.position, skelly.transform.position);
         if (distance <= 3)
         {
             skelly.animation.CrossFadeQueued("run", 0.3f, QueueMode.PlayNow);
         }
         else if (distance < 15 && distance > 5.0f)
         {
             skelly.animation.CrossFadeQueued("attack", 0.3f, QueueMode.PlayNow);
             skelly.animation.CrossFade("run");
             skelly.transform.LookAt(player.transform.position);
             skelly.transform.position = Vector3.MoveTowards(skelly.transform.position, player.transform.position, speed);
         }
         else
         {
             skelly.animation.CrossFadeQueued("run", 0.3f, QueueMode.PlayNow);
             skelly.animation.CrossFade("idle");
         }
     }
 }
Comment
Add comment · Show 3 · 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 X_rploader Boss · Jan 01, 2015 at 05:04 PM 0
Share

when I run the game it says:

$$anonymous$$issingComponentException: There is no 'Animation' attached to the "skeleton" game object, but a script is trying to access it. You probably need to add a Animation to the game object "skeleton". Or your script needs to check if the component is attached before using it. UnityEngine.Animation.CrossFadeQueued (System.String animation, Single fadeLength, Queue$$anonymous$$ode queue) (at C:/BuildAgent/work/d63dfc6385190b60/artifacts/EditorGenerated/Animations.cs:613) Skellyattack.Update () (at Assets/Skellyattack.cs:36)

avatar image tanoshimi · Jan 01, 2015 at 05:36 PM 0
Share

Ok, and what do you think that error message might mean...?

avatar image X_rploader Boss · Jan 01, 2015 at 08:20 PM 0
Share

i think I added an animation for it

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

Parsing error in no error script. 1 Answer

String Parsing 1 Answer

Initialising List array for use in a custom Editor 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges