• 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 /
avatar image
0
Question by Phyro_Millenia · May 10, 2016 at 06:38 AM · unity 52d-platformeranimation controller

Need suggestion or advice on my 2d platformer

Need suggestion or advice on my 2d platformer

Hi, this is my first time posting in here. I have been studying how to create a 2D platformer for nearly a week. I used the GBA Castlevania Aria of Sorrow as the reference to recreate the control on Soma Cruz. I have recreated a few of his major movement with animation controller. Currently I am having a problem deciding how to arrange or change the node in the Animator, because it have become messy.

There are two think I need help with.

1- What further improvement can I do to the Animator controller (Image below)?

2- I need some criticism on the PlayerController C# Script I have.

Thanks

alt text

 void Start ()
     {
         r2d = GetComponent<Rigidbody2D> ();
         cColl = GetComponent<CircleCollider2D> ();
         rend = GetComponent<SpriteRenderer> ();
         anim = GetComponent<Animator> ();
         afterimage = transform.FindChild("AfterImage").gameObject;
     }
 
 void Update ()
 {
         anim.SetFloat("verticalSpeed", r2d.velocity.y);
         direction = 0.0f;
 
         if (isGrounded)
         {
             anim.SetInteger ("state", 0); // Idle
         }
         else
         {
             anim.SetInteger ("state", 3); // Fall
         }
         anim.SetBool("isGrounded",isGrounded);
 
         if (!isBackDashing)
         {
             if (Input.GetKey(KeyCode.RightArrow))                         //Move Right
             {
                 rend.flipX = false;          // Face Right
                 anim.SetInteger("state", 1); // Walk
                 direction = 1.0f;            // To The Right
             }
             
             if (Input.GetKey(KeyCode.LeftArrow))                          //Move Left
             {
                 rend.flipX = true;           // Face Left
                 anim.SetInteger("state", 1); // Walk
                 direction = -1.0f;           // To The Left
             }
             
             if (Input.GetKey(KeyCode.DownArrow) && isGrounded)            //Crouch/Duck
             {
                 direction = 0.0f;            // Stop And
                 anim.SetInteger("state", 2); // Duck
             }
             
                   if (Input.GetKey(KeyCode.UpArrow))                      //Cast
                   {
                           //Blank
                   }
         }
 
         if (Input.GetKeyDown(KeyCode.Z)                            //Jump
             && isGrounded && anim.GetInteger("state") != 2)
         {
             if (isBackDashing)
             {
                 isBackDashing = false;
                 afterimage.SetActive(false);
             }
             r2d.velocity = new Vector2(r2d.velocity.x,jumpHeight);
 
             anim.SetInteger("state", 3); // Jump
             anim.SetBool("isGrounded",isGrounded);
         }
 
         if (Input.GetKeyDown(KeyCode.A)                         //BackDash
             && isGrounded && !isBackDashing)
         {
             isBackDashing = true;
             afterimage.SetActive(true);
         }
 
         if (isBackDashing)
         {
             if (rend.flipX)
             {
                 r2d.velocity = new Vector2(backDashSpeed,r2d.velocity.y);
                 anim.SetInteger("state", 4);
             }
             else
             {
                 r2d.velocity = new Vector2(-backDashSpeed,r2d.velocity.y);
                 anim.SetInteger("state", 4);
             }
         }
         else
         {
             r2d.velocity = new Vector2(direction * walkSpeed,r2d.velocity.y);
         }
 }

animationcontroller.png (123.0 kB)
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 Highwalker · May 10, 2016 at 07:05 AM 0
Share

It seems like all your animations connect to all the animations and don't necessarily rely on a flow of sorts. So why not use the Any State feature?

avatar image Phyro_Millenia Highwalker · May 10, 2016 at 07:55 AM 0
Share

I'm not sure weather to use it or not that is where my problem is. The Any State node is one of the option that is currently on the table, I will have to look into this further.

0 Replies

· Add your reply
  • Sort: 

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

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

How do i change the sprite on a sprite renderer without changing the size? 1 Answer

Unity doesn't open mi project 0 Answers

2D Platformer Pick up and move object script help! 1 Answer

Need my character to move with platform,I need to make it so when i touch anything with the tag mov platform my character moves with it 0 Answers

2D game Unity5 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