Method similar to Unity's SmoothDamp?

0 favourites
  • 7 posts
From the Asset Store
Construct 3 Plugin Unity Ads, Banner, Interstitial Ads, Video (Support C3 build service)
  • Is there a way to to something similar to Unity's SmoothDamp Method? The way it works is like this(leaving out some bits):

    SmoothDamp(5,100,6)

    And then it transition 5 to 100 over the course of 6 seconds. While returning the value every time it changes. So you could change opacity and such over the course of however long, smoothly. Anyone know how I can do this?

  • It can probably be done using a "advanced" lerp function depending if you want a regular increase or not ... using lerp the problem is the third parameter and math is my nemesis so ... i let "expert" give you a more complete answer ! ... it can perhaps be done using a "sin" too

    A very interesting post (not as mine ;-p) about this kind of effects

    interpolation

    thanks for this very interesting post !

    Perhaps something more simple ... if you add dt to a variable every tick, it adds 1 to this variable every second so consider "x" = "targetvalue-value" must be reach in 6 seconds perhaps :

    every tick :

    value = value + dt * (x/6) ?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • DoubleElite you have found something else ? ... my answer is good, not good ? and why ?

    Sorry but people requesting for help and forgetting they have do so ... it's really something i don't like at all ...

  • I tried to experiment with your idea to lerp() expression, well it didn't, maybe i did wrong, anyways i would love to see a proof...

  • It depends on your interpretation of "smooth".

    Lerp offers a transition similar, but its a curve so the start, and end can be slower than the middle. Ease out, ease in if you will.

    Also you cant really do exactly 6 seconds, nor should you expect that in a system that goes on frame rate.

    However, if that's not terribly important, you can get a close approximation using dt.

    I'd suggest some experimentation with variables as triggers if you absolutely have to that kind of precession.

    Just be ready for frame skips.

  • Try this to have a sprite change it's x from 5 to 100 in 6 seconds after a click.

    global variable start_value=5

    global variable end_value=100

    global variable duration=6

    global variable start_time=0

    +On click

    --- set start_time to time

    +time < start_time+duration

    --- Sprite: set x to lerp(start_value, end_value, (time-start_time)/duration)

    +time >= start_time+duration

    +trigger once

    --- Sprite: set x to end_value

  • You could try taking a look at this behaviour easytween by lunarray

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)