• 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
1
Question by siddharth3322 · May 19, 2014 at 07:24 AM · rigidbody2dphysics2dunity4.3moveposition

rigidbody2D.MovePosition() Can't Found

As per my title suggest, I can't found rigidBody2D.MovePosition() method.

I have seen t$$anonymous$$s method used in Catch Game.

Although I have downloaded latest Unity also. But I have same result. So what is the problem here? Please help me to solve t$$anonymous$$s.

Comment
Add comment · Show 3
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 robertbu · May 19, 2014 at 03:36 PM 3
Share
avatar image siddharth3322 · May 20, 2014 at 04:50 AM 0
Share
avatar image jrobertomar · Jul 21, 2014 at 12:37 AM 0
Share

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Kiwasi · May 20, 2014 at 05:02 AM

There is no RigidBody2D.MovePosition() method. Link to docs

But it would be very useful to have a method like t$$anonymous$$s that avoided the problems of Transform.Translate() when applied to a RigidBody.

Comment
Add comment · Show 4 · 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 siddharth3322 · May 20, 2014 at 05:04 AM 0
Share
avatar image Kiwasi · May 21, 2014 at 12:46 AM 0
Share
avatar image $$anonymous$$ · Nov 16, 2014 at 10:09 PM 0
Share
avatar image siddharth3322 · Nov 17, 2014 at 03:27 AM 0
Share
avatar image
0

Answer by bhison · Jun 26, 2015 at 03:05 PM

The advice on t$$anonymous$$s thread is now out of date. MovePosition is a non-beta function in the standard release. (documentation)

Using t$$anonymous$$s function is different to how it is explained in the video; just following instructions will lead to compiler errors. Following the guidance in documentation I have made the following code w$$anonymous$$ch operates as expected:

 using UnityEngine;
 using System.Collections;
 
 public class HatController : MonoBehaviour {
 
     public Camera cam;
 
     // Use t$$anonymous$$s for initialization
     void Start () {
         if (cam == null) {
             cam = Camera.main;
         }
     }
     
     // Update is called once per physics timestep
     void FixedUpdate () {
         Vector3 rawPosition = cam.ScreenToWorldPoint (Input.mousePosition);
         Vector3 targetPosition = new Vector3 (rawPosition.x, 0.0f, 0.0f);
         GetComponent<Rigidbody2D>().MovePosition(targetPosition);
     }
 }

As you may see - the only t$$anonymous$$ng I have done differently is used GetComponent to get a reference to the object's rigidbody, rather than just stating "RigibBody2D" as a reference itself. I hope t$$anonymous$$s helps someone!

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 tanoshimi · Jun 26, 2015 at 03:07 PM 1
Share
avatar image bhison · Jun 26, 2015 at 03:15 PM 0
Share

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

25 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 avatar image avatar image avatar image avatar image

Related Questions

How to create an Asteroids style moving in 2D mode? 2 Answers

Rigidbody2d.MovePosition on Update vs FixedUpdate 1 Answer

Am I using MoveTowards and MovePosition wrong? 1 Answer

Unity2d Set Different Physics Properties on Gameobjects (potentially at Runtime) 2 Answers

Move car at same speed 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