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
3
Question by icetrap · Oct 27, 2011 at 12:45 AM · gameobjectsteleporting

Clearing out an objects force when trying to teleport it.

I am currently writing some logic that after the game has finished I want to reset all of our current game objects back to their starting locations. I can get the objects to get teleported back to their correct starting locations but it seems after the game countdown and I reenable their activity they will thrust forward. Or in what ever direction they were heading when I teleported it. Is there a way to clear an objects force?

This is how I am teleporting my object.

 playerObject.transform.position = startingPosition.transform.position;
 playerObject.transform.rotation = startingPosition.transform.rotation;
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

3 Replies

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

Answer by green_core · Oct 27, 2011 at 06:22 AM

To clear forces you need to set rigidbody.velocity and rigidbody.angularVelocity to zero.

 rigidbody.velocity = Vector3.zero;
 rigidbody.angularVelocity = Vector3.zero;

If you forget about angular velocity then objects will continue rotating.

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 icetrap · Oct 27, 2011 at 04:33 PM 0
Share

worked great thanks!

avatar image Guppie1337 · Jan 08, 2015 at 10:43 PM 0
Share

Worked great for me for a different purpose. I tried to figure this out myself for about an hour but no luck. Thanks for the info.

avatar image
-1

Answer by YJack · Oct 27, 2011 at 02:55 AM

You can use change your velocity with: rigidbody.velocity = Vector3.zero; But you might want to destroy and re-instantiate your object with: Destroy (gameObject); Instantiate (prefab, Vector3.zero, Quaternion.identity);

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 SirMacJefferson · Oct 27, 2011 at 04:06 AM

Do they have rigidbodies attached to them and are you manipulating their velocity/adding force to them in any way? If so, just set their velocity to Vector3.zero like so:

rigidbody.velocity = Vector3.zero;

If you're manipulating their position without use of rigidbodies, then it must have something to do with your system.

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

How to recreate a gameobject if i have destroyed it and want to recreate it on same scene on same time ? 0 Answers

how to get child objects transform in arry ? 1 Answer

Flashlight 1 Answer

Line of Disappearance? (or some other more relevant term),How to make an area where a shape will disappear into? 0 Answers

Same script not working on next level 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