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 wbl1 · Feb 23, 2011 at 08:59 PM · movementaccelerationanimationcurve

moving in a straight line, but variable speed

So I am moving a car in a straight line but I want it to accelerate up to a maximum speed. I am thinking that animationCurve is a good way to go, but am not exactly sure how to execute this. How would I set up an animationCurve and use it to drive the car's transform?

Expanding a bit:

at t=0 sec, xPosition = 0 at t=1 sec, xPosition = 0.5 at t=2 sec, xPosition = 1.5 at t=3 sec, xPosition = 4.5

... and so on. Was thinking these values for t and xPosition would simply represent the keyFrames in an accelerationCurve. Does this sound right? If so, could anyone throw together some quick code to show me how to do this?

Thanks!

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
1
Best Answer

Answer by PrimeDerektive · Feb 23, 2011 at 09:13 PM

Hmm, that sounds like a terrible idea. To accelerate up to a maximum velocity, I would make the car object a rigidbody and do something like this (very basic example):

var accel : float = 3.0; var maxSpeed : float = 30.0;

function FixedUpdate(){ if(rigidbody.velocity.magnitude < maxSpeed) rigidbody.AddForce(Vector3.forward*accel); }

Comment
Add comment · Show 3 · 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 wbl1 · Feb 24, 2011 at 02:21 PM 0
Share

But, if I changed the example to something other than velocity, acceleration etc (thus we did not have the physics engine), would this be an appropriate use of accelerationCurve. I am just trying to understand what its about ... Thanks

avatar image PrimeDerektive · Feb 24, 2011 at 02:53 PM 1
Share

Then I would use transform.translate, and do a similar thing (but you'd have to measure velocity yourself). Animation curves are for animated models with animation clips (for instance, a human model with a walk animation or a punch animation). I wouldn't handle actual movement with animations.

avatar image wbl1 · Feb 24, 2011 at 06:25 PM 0
Share

O$$anonymous$$, thanks. Appreciate your help!

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

No one has followed this question yet.

Related Questions

Move Player without acceleration 1 Answer

Rigidybody2D addforce at constant speed 1 Answer

How do I make and object move in sync with its animation? 1 Answer

Add acceleration to movement 0 Answers

Player not moving even though input is working 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