Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional option to tween by speed #25

Open
marcusx2 opened this issue Nov 23, 2021 · 6 comments
Open

Additional option to tween by speed #25

marcusx2 opened this issue Nov 23, 2021 · 6 comments

Comments

@marcusx2
Copy link

It would be nice if we could pass a speed parameter for tweening instead of duration. It would be useful if you want to move from point x to point y at a constant speed regardless of the distance of said points. With only the duration, a movement tween can happen faster or slower depending on the distance between point x and point y.

@marcusx2 marcusx2 changed the title tween by speed, not duration Additional option to tween by speed. Nov 23, 2021
@marcusx2 marcusx2 changed the title Additional option to tween by speed. Additional option to tween by speed Nov 23, 2021
@yaustar
Copy link
Collaborator

yaustar commented Nov 23, 2021

Going at a constant speed isn't a tween. Tweening in animation is a short for inbetweening and it's the process of generating images that go between keyframes.

Keyframes are on a timeline so having an option to tween by speed doesn't make sense for a tweening library.

It's sounds like you want something like Unity's MoveTowards function. If so, you can get the code from the Unity GitHub repo where they've made their C# code public.

@marcusx2
Copy link
Author

Well I've seen plenty of tweening libraries with this option before, even if it's not technically tweening.

@yaustar
Copy link
Collaborator

yaustar commented Nov 23, 2021

Can you link to them please? It will help with working out what API people are used to if we do implement something like this.

@marcusx2
Copy link
Author

marcusx2 commented Nov 24, 2021

Well if the user provides the speed you can get the time with time = (distance / speed) * dt; right? The distance variable will change based on what you are trying to tween. If it's a movement tween distance is really the distance between two vectors, but if you are trying to tween, idk, the color of something, distance will be something else. But that's the gist of it.

Hm let's see an example http://dotween.demigiant.com/documentation.php. Search for Tweener-specific settings and options and then look into the SetSpeedBased option.

@yaustar
Copy link
Collaborator

yaustar commented Nov 24, 2021

Yeah, this is the part where I feel like it doesn't belong in a tween library:

image

It basically becomes a standard lerp as it the easing option are basically ignored which is the main feature.

I can see a case for it all that said so consideration will be given to add this or consider a PR

@marcusx2
Copy link
Author

as it the easing option are basically ignored which is the main feature.

Only if the interpolator is linear.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants