Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 tertle · Jun 01, 2011 at 02:47 AM · rigidbodymovepathing

rigidbody.MovePosition result makes no sense

Using rigidbody.MovePosition for a pathing script but the results that occur make no sense.

Simplified script of the problem

 void FixedUpdate()
 {
     print("position" + rigidbody.position);
     rigidbody.MovePosition(new Vector3(-365.0f, 8.9f, 130.0f));
 }

Returns this,

 position(-365.0, 9.0, 130.0) // Initial position of object before a move
 position(-365.0, 9.6, 129.9) // Random? postion after first move
 position(-365.0, 8.9, 130.0) // Position it was meant to move to

I can't understand why it flies off to some weird value for 1 iteration then goes to value it's meant to.

-edit-

http://ninjatertle.com/dump/moveposition.unitypackage

Completely empty scene except a camera and 1 rigidbody with a script with the above code. It oscillates on the spot between the correct position and 0.7 higher.

Only thing I can think of is there is something wrong with my exported model.

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

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Eric5h5 · Jun 01, 2011 at 02:53 AM

If there's nothing in the way and the rigidbody isn't interacting with anything else, it will go to the position specified. Clearly you have some other object(s) it's interacting with. If you want an object to go to a specific position without any collisions, use transform.position and no rigidbody.

Comment
Add comment · Show 5 · 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 tertle · Jun 01, 2011 at 03:07 AM 0
Share

Test scene is completely devoid of any other object except a camera. And that script above attached to an object. http://ninjatertle.com/dump/moveposition.unitypackage And yes since my player is a rigidbody I need collisions.

avatar image Eric5h5 · Jun 01, 2011 at 03:17 AM 0
Share

@tertle: your object has an animation on it. Remove the animation.

avatar image tertle · Jun 01, 2011 at 03:22 AM 0
Share

Doesn't seem to help, but turning on interpolation seemed to fix it. Thanks anyway.

avatar image Eric5h5 · Jun 01, 2011 at 04:13 AM 0
Share

@tertle: Try that script on a Unity primitive to see what I mean. The animation is causing the object to move. Removing the animation will actually fix the problem, ins$$anonymous$$d of just sort of working around it.

avatar image tertle · Jun 01, 2011 at 05:22 AM 0
Share

I tried on primitives and you're right the issue doesn't occur, but it still doesn't seem to work on the custom mesh, even when I remove the (empty) animation. I have since tried on a few other meshes, square meshes don't seem to have issues but anything with an awkward mesh has an unusual first move. After that the shape moves fine even if I change trajectory.

avatar image
0

Answer by tertle · Jun 01, 2011 at 03:21 AM

Turning on interpolation seems to have (pretty much) solved it for me. Very minor jitter around point, but doesn't go opposite direction at start.

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.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Rigidbody.MovePosition() moves only in the GLOBAL z axis (forward and backward) 1 Answer

How to make rigidbody.AddForce and controller.Move work together? 0 Answers

Moving a GameObject with a script from another GameObject (Rigidbody) 1 Answer

Moving a rigidbody onto exact mouse position using rigidbody.MovePosition? 1 Answer

Problems with CharacterController.Move 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