• 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
1
Question by Shar1ngan · Feb 07, 2013 at 12:05 PM · c#character controllerplatform

2d character controller moving by platform

I'm doing a 2d platformer with 2D toolkit.

The character is controlled with a standard character controller.

Please help me how to make a move by the platform.

If I make the platform parent to the player is buggy (flying from side to side.) Rigidbody attach impossible.

If i do:

 transform.position =
    new Vector3(Platform.transform.position.x,transform.position.y,0)


player twitches and can not walk on the platform.

If i use standart platform input controller he don't work too.

What should I do?

P.s. Sorry for my bad English I'm not a native speaker.

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 iwaldrop · Feb 12, 2013 at 06:19 AM 0
Share

One technique I've used recently, because it is so simple, is to just child the player to the platform when its on it, and unchild it when you're done. This way the child can still move about under the parent, and when the parent moves the child moves with it automatically.

avatar image LoserKidKlazy · Feb 14, 2013 at 01:16 AM 0
Share

You can add debug statements all over the code to find out whats happening. I do that a lot when i have weird issues. That usually helps out.

 print("Walk Speed = " + walkSpeed);

Stick couple of those in your code find our what fires when the player is on the platform, then set up some new print() and pass in some variables. I think the first place to star is looking at isGrounded while you players on the platform.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by LoserKidKlazy · Feb 12, 2013 at 06:41 AM

First issue, you need to add the standard character controller to the player then attach as custom script that uses the standard character controller. This script will be you actual controller and will handle you Input for the keyboard of controller.

You will need this two lines of code. The first lets you use the 2D Toolkit animation stuff. The second gives you access to the std controller. (this is in C#)

 [AddComponentMenu("2D Toolkit/Demo/tk2dDemoAnimController")]
 [RequireComponent(typeof(CharacterController))]

this blogged helped me out a lot. http://walkerboystudio.com/html/unity_course_lab_4.html Part 4-13 is all controller setup.

Second issue, The twitching. I think this is an issue with Unity's standard controller. It seems like any time the bounding box changes, isGrounded becomes false for a few update cycles. If your using 2D Toolkits Tile Editor, this is a HUGE issue, cause even though it looks like on solid bounding boxed the controller only see the collision of EACH tile. Im not sure why other people dont have this issue but it seems to happen with any bounding box even if they are not part of 2D Toolkit and /or are overlapping. Its any time the bounding box changes. My solution was to build a solid bounding box on an Empty GameObject then place it in the right location and move the object as a child of the tile map.

I hope this helps. If you need more help then the WalkerBrothers, check out the 3rd Person Platformer Starter Kit. You can modify that player controller to work 2D.

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

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

12 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

Related Questions

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

Rigidbody Keep Vertical Without Applying Rotational Constraints 2 Answers

Falling through the floor 1 Answer

Moving character along the global axis 0 Answers


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