• 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 Tixed · Apr 18, 2010 at 11:57 AM · 2dmovementphysics

thruster-like 2d movement

I want to make a simple game with Spore-like movement for my player character (first stage, "cell"). For thosue unfamiliar with that game, it's in complete 2D, user point and click direction he want to move, then character model rotate its "front" to that point and then follow the pointer until mouse button is released. Two major questions here are: 1) how can I make usual physics stick to 2D in all movement, collisions, etc; 2) how can I make smooth rotation and movement (with a bit of inertia). I'm quite new to Unity, so few examples of scripting something similar would be excellent. I've tried to modify standart DragRigidbody script to my needs, but I feel that it's not exactly right for this purpose, but maybe joints are what I need. JavaScript and C# are both welcome.

Comment
Add comment · Show 1
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 spinaljack · Apr 18, 2010 at 12:12 PM 0
Share

Looks like a lot of questions here. You should split them up into individual posts to make searching and referencing easier.

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by spinaljack · Apr 18, 2010 at 12:20 PM

1)You can add a plane or terrain across the scene and have the camera look down the y-axis, gravity should keep everything on the same level, you might also try putting an invisible collider across the top of everything to form a low ceiling maybe. Putting the camera into orthographic view makes for a 2D effect.

Better yet use a configurable joint to restrict movement in one of the planes and your objects will always be in 2D movement.

2)If you are using the built in physics engine then you can use the drag variable of the rigid body for inertia, angular drag also slows down spinning motions. Use rigidbody.addforce for thruster like movement. There's an add torque function as well but it's easier just the manipulate the rotation directly.

Here's a 2D game tutorial complete with assets

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 Muuskii · Jul 17, 2012 at 01:42 AM

Whenever I'm making a Rigidbody that's supposed to operate is 2D I just go into the Rigidbody's constraint tab and click on Y in "freeze Position" then X and Z in "freeze Rotation"

This stops the object from moving up and down plus halts rotation coming off the plane. If it's not a Rigidbody then you can just set position.y = some fixed value and rotation = fixed except yrotation

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

1 Person is following this question.

avatar image

Related Questions

Character still walking when no key is already pressed 1 Answer

How can I make 2D movement less jerky on a controller, with velocity and such? 0 Answers

How can I make 2D movement the same on controller and keyboard? 0 Answers

2d topdown physics 2 Answers

Having problems with animation and movement of 2D Character 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