• 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 Nexgea · Nov 26, 2013 at 06:46 PM · 2drigidbody

Can you help me ?

I saw in one tutorial this code"

function Awake() { rigidbody.AddForce(4, 4, 0, ForceMode.Impuls); } but this is for 3D rigidbody. Do u know how can i convert this code into "2D"? (I try this:

function Awake() { rigidbody2D.AddForce(4, 4, ForceMode.Impuls); } but it is error : Assets/Scripts/Ball.js(4,29): BCE0017: The best overload for the method 'UnityEngine.Rigidbody2D.AddForce(UnityEngine.Vector2)' is not compatible with the argument list '(int, int, System.Object)'.

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 Spinnernicholas · Nov 30, 2013 at 12:34 AM 0
Share

knock knock, how goes it?

3 Replies

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

Answer by TaylorAnderson · Nov 26, 2013 at 07:01 PM

I would suggest making a more descriptive title if you want more people to read your post. As for your question, the error message is fairly descriptive: you need to make sure that the variables your passing into the function match the type of variables the function is looking for. In this case, instead of putting rigidbody.AddForce(4, 4, 0, ForceMode.Impuls), you have to put rigidbody.AddForce(new Vector2(4, 4), ForceMode.Impuls).

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 sdgd · Nov 26, 2013 at 07:40 PM 1
Share

if this is your correct answer you should accept it!!!

avatar image
0

Answer by Soozle · Nov 26, 2013 at 06:57 PM

Here, this should help you: http://docs.unity3d.com/Documentation/Components/class-Rigidbody2D.html

Comment
Add comment · Show 2 · 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 Nexgea · Nov 26, 2013 at 07:26 PM 0
Share

Sorry thats shouldnt help me :(

avatar image sdgd Nexgea · Nov 26, 2013 at 07:36 PM 1
Share

Please don't post answer as comment and please learn to make a good title

this kind of questions should be automatically rejected because of bad title.

AND LEARN TO $$anonymous$$A$$anonymous$$E A CODE Sample

there's 101010 button on top if you highlight your code and pess that button we can read your code afterwards!!!

if you would be able to get in to - karma I'd downvote you 3 times.

so everyone in moderation queue would know to in most cases automatically reject you.

so you'd have to make a pretty good job doing a Q

avatar image
0

Answer by Spinnernicholas · Nov 26, 2013 at 07:45 PM

 function Awake()
 {
   rigidbody2D.AddForce(new Vector2(4, 4)); 
 } 

This is the best you can do it because there is no force mode for the 2d rigid body. Should have same results because the force is only applied once, making it instant.

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

21 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

Related Questions

2D Mouse Look with Collisions 1 Answer

wasd movement rigidbody no bouncing 0 Answers

rigidbody.useGravity doesnt work? 1 Answer

2D Game, Character Slides off Slopes, Need to be Able to Walk on Them 1 Answer

C# OnCollisionEnter2D Not Occuring 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