Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

[Help] Can i make speed grow?

Discussion in 'Getting Started' started by Aress28, Feb 6, 2016.

  1. Aress28

    Aress28

    Joined:
    Dec 12, 2015
    Posts:
    100
    Hello! Im new here...
    Is it possible to make speed grow for like 0 to 60 in like 5 secs or so...i want speed to grow not instant 60...And it must start speed up after mouse click to destination(like in RTS units move).
    Can we do it? can some give sample or line of code , idea?
     
  2. larku

    larku

    Joined:
    Mar 14, 2013
    Posts:
    1,422
    I'm not really sure what you're asking, but to change create a speed-up or slow-mo effect you can use
    Time.timeScale.

    For example,

    Time.timeScale = 0.5f;

    Would be half speed,

    Time.timeScale = 2f;

    Would be double speed.

    Note, this will effect everything that is time dependant.
     
    MikeTeavee likes this.
  3. MikeTeavee

    MikeTeavee

    Joined:
    May 22, 2015
    Posts:
    194
    (curious) What is a speed grow?
     
  4. tedthebug

    tedthebug

    Joined:
    May 6, 2015
    Posts:
    2,570
    I think it is movement speed so the player accelerates & decelerates instead of instant full speed & instant stop.

    If you are using physics you can use addforce & then clamp the maximum velocity so they don't accelerate to infinity. Also normalise it so they don't go faster on the diagonals. To slow down you can apply a negative force or play around with friction & stuff.

    I'd suggest starting with the unity tutorials with the roll a ball one & then do the space shooter as they will introduce you to all the concepts & then you can work out what you need.

    https://unity3d.com/learn/tutorials


    Good luck
     
    JoeStrout likes this.
  5. Aress28

    Aress28

    Joined:
    Dec 12, 2015
    Posts:
    100
    goal is to get like in this demo http://demo1.lustrousgames.com/ when u click its move but in this demo its move with speed lets say float speed = 60; so i need my car or tank what ever - first 10% of distance its accelerate speed from 0 to 60 and then till 90% of distance its go full speed and from 90% to finish its slow down from 60 - 0...
     
  6. DuffyT

    DuffyT

    Joined:
    Dec 16, 2014
    Posts:
    37
    If you make your gameobject (tank, car, ...) move using normal input (keys), you can use Input.getaxis in conjunction with the gravity/sensitivity in the inputmanager. Multiply that value with your movement and it will fall/rise as you want.

    http://docs.unity3d.com/Manual/ConventionalGameInput.html --> Look for gravity and sensitivity.
     
  7. Aress28

    Aress28

    Joined:
    Dec 12, 2015
    Posts:
    100
    Im try to make from normal input(keys) to mouse clicks
     
  8. tedthebug

    tedthebug

    Joined:
    May 6, 2015
    Posts:
    2,570
    Spend time actually doing these tutorials, they will explain the basics. Then move onto the other ones in the subsections to get into more specific detail.

    https://unity3d.com/learn/tutorials