• 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 /
  • Help Room /
avatar image
0
Question by Kimone92 · May 09, 2016 at 07:55 PM · scripting problemscripting beginnerscript error

Please Help With Script

alt text

using UnityEngine; using System.Collections;

public class Enemy : Character {

 private IEnemyState currentState;

 public GameObject Target { get; set; 

 // Use this for initialization
 public override void Start () 
 {
     base.Start ();

     ChangeState (new IdleState ());
 }
 
 // Update is called once per frame
 void Update () 
 {
     currentState.Execute ();
 }

 public void ChangeState(IEnemyState newState)
 {
     if (currentState != null)
     {
         currentState.Exit ();
     }

     currentState = newState;

     currentState.Enter (this);
 }

 public void Move()
 {
     MyAnimator.SetFloat("speed", 1);

     transform.Translate (GetDirection () * (movementSpeed * Time.deltaTime));
 }

 public Vector2 GetDirection()
 {
     return facingRight ? Vector2.right : Vector2.left;
 }

 void OnTriggerEnter2D(Collider2D other)
 {
     currentState.OnTriggerEnter (other);
 }

}

screen-shot-2016-05-09-at-214838.png (209.1 kB)
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by TBruce · May 09, 2016 at 08:42 PM

@Kimone92

This

 public GameObject Target
 { get; set; 

should be this

 public GameObject Target
 { get; set; }
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 Kimone92 · May 10, 2016 at 09:30 AM 0
Share

Thank you very much! Worked like a charm!

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

62 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Getting weird error message!?!?!? 1 Answer

How do i make my enemies face the player? 2D 0 Answers

Object reference not set to instance for my timer and my text 0 Answers

Error CS1519 1 Answer

hey! this problem has been bugging me cs1525 unexpected symbol `quaternion' can you please help we with this problem. 1 Answer

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