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
0
Question by Rush3fan · Jan 19, 2012 at 01:45 PM · rigidbodypositionvelocitysetting

Is there a way to set velocity while setting the position?

I noticed when I try to set the position of a rigidbody, it doesn't change velocity.

Is there any easy way to set the position and having the game engine automatically recognize what the velocity is supposed to be?

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by adrenak · Jan 19, 2012 at 06:17 PM

Unity can't assume with what velocity you want to go because it depends on how much time you want the object to take for it to go from point A to B. But theres a really simple method of moving a object to a point with a desired velocity :

 var destintationPoint : Transform;  //place you wanna go
 var speed : float;  //speed with which you wanna go
 
 function Update () {
     transform.position = Vector3.Lerp(transform.position, destinationPoint.position, Time.time * speed);
     //or you can use substitute Lerp with MoveTowards for a more uniform velocity 
 
 }

I Hope this helps.

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 Rush3fan · Jan 20, 2012 at 02:20 AM 0
Share

But see, when you are moving an object with transform.position=, even smoothly, the actual velocity of the rigidbody stays at zero because you are only changing the position.

So, imagine a car traveling 50mph and for one script loop, you set the transform.position to (0,0,0). The car is going to keep going 50mph from that point.

In a different game engine I used before, there was an auto velocity feature where in that same case, it would detect the change and stop the car completely.

This is just an example though.. The problem I'm currently dealing with is a little more complex.

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

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How can I increase or decrease a position based on another variable ? 1 Answer

Problem stopping rigid body after adding a force 0 Answers

Velocity powered rigidbody on a moving platform without parenting. 3 Answers

Get Interpolated rigidbody velocity 1 Answer

Take final position after a force applied to a GameObject 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