Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
avatar image
0
Question by que_cide · Oct 21, 2013 at 02:47 PM · raycast2d-platformercharacter controllerplatformridgidbody

2D platformer. What is the best option for the main Character?

Hello. I have recently been looking into building a 2d platformer using Unity and was hoping to get some input as to what type of system I should use for the main character and their movements.

I currently want something like Mario,braid,limbo,fez, something similar. I know/understand that they have built their own engines but I am also certain that something similar can be achieved in unity.

I have found three options that will work, but each have their own advantages and drawbacks.

  1. Ridged bodies

  2. Character Controller

  3. Raycast

I am leaning towards Raycast just because that will give me the most control over what the character does, but I am having difficulties with slopes and platforms moving up/down and looking normal.

What do you think would be the best option and if I am missing any please feel free to speak up.

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 yveris · Oct 21, 2013 at 03:12 PM

It depends of course on the context of the game you are creating, if you don't require specific physics based functions then I wouldn't suggest using the rigidbody approach. This will hand off the control to the physics engine and any sort of translations or manual, so to speak, movements of your character will result in undefined behavior. (Translating through walls, improper velocities, directional anomalies). But if physics is what you are looking for (I am also making a 2D platformer based on physics puzzles for example) rigidbody is your best choice for realistic physics calculations.

Character controllers on the other hand are easier to use so to speak, they don't require knowledge of physics and work in a more simplified manner, that is they are easier to use in certain ways of predictability (given you don't have a physics background) and maneuverability.

Character controllers also don't use your oncollision functions. They inherit from Collider and will have the function; however, if you do not have a rigidbody it won't fire the event handler. This thread has an example at the end of function message passing, which is somewhat expensive but it will work for character controller collision detection. But also there's this function. I haven't used the character controller, I as previously stated use the rigidbody. So I can't speak for the effectiveness of that method.

I don't know much about using raycast. :(.

But to summarize my point: If you need real physics use rigidbodies with the caveats expressed above, but if you don't or you want to script your own physics and circumvent the physics engine of unity use character controllers I would think.

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 que_cide · Oct 21, 2013 at 04:49 PM 0
Share

Thank you for your detailed reply. I do want my platformer to have physics on certain objects. I'll take a closer look into rigidbodies and how they can be used. I might even do half/half with raycasting to get the correct moves down.

Thank you again for your information, I am always looking for feedback from other platformer devs.

avatar image yveris · Oct 21, 2013 at 07:41 PM 0
Share

I'm currently using vector3 translate functions and physics. Just keep in $$anonymous$$d that this can cause some weird behavior at high velocities. If you're using this when you jump you'll have to store the translation speed if you want the fake inertia to maintain itself through the jump and you can script velocity slowing down while in the air as well.

avatar image meat5000 ♦ · Oct 21, 2013 at 07:44 PM 0
Share

If you are happy with the answer, please accept

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.

Follow this Question

Answers Answers and Comments

16 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

Related Questions

Gun script using Physics.Raycast not working? 2 Answers

Physics.Raycast doesn't hit anything even though Debug.DrawRay works 1 Answer

Finding any objects below or above object at ANY POINT? 1 Answer

Move Forward or Turn based on action recieved. 3 Answers

How to disable wall jumping in 2D platformer with raycast and tilemap? 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