Comments (9)
Setting it to 0.001f instead of 0 will work. Obviously it's not ideal, so it's something that should probably be fixed at some point, but it will give basically the same result.
from gokit.
yup. using float.epsilon now
from gokit.
I realize you've stated that you've rectified this problem, however I'm experiencing this error.
When I perform this function call the property is set to NaN, but if I set the duration to 0.001f it will correctly set itself to 0f.
public TextboxManager Hide(float duration = 1f) {
UIPanel panelToModify = this.gameObject.GetComponent<UIPanel>();
panelToModify.alpha = 1f;
Go.to(panelToModify,
duration,
new GoTweenConfig()
.floatProp("alpha", 0f));
return this;
}
Do you have any suggestions on how to rectify this?
from gokit.
Are you saying you are having the problem when you set duration to 0?
If so, it's a bit of a problem to have a 0 duration tween for us, as it's a bit difficult to figure out which events people would expect to be firing.
If you want an immediate answer that doesn't rely on a GoKit fix, just add this line in the top of your function:
duration = Mathf.Max(duration, Mathf.Epsilon);
from gokit.
Ah, yeah. That was the route I ended up going, based on the initial solution provided here.
However, could you elaborate on the problem with the events people would be expecting to be fired. I'm afraid I'm not sure what you're communicating.
My perception of this issue is then when the value is being tweened is inclusive of the end value it should default to the end tween value and not something like "NaN".
Or if not, maybe just add something to error catch a 0f and instead pass Mathf.Epsilon instead of just allowing a bad value like that to continue propagating as a side effect/bug?
As a user of the code, I do not anticipate that by having a 0 duration on my tween that it'll affect my code in such a way. So, it seems like it should be fixed or handled more gracefully.
from gokit.
This is definitely one than can go either way. A zero duration tween could either be an error that throws or gracefully hides the situation by reverting to epsilon. I would personally lean toward throwing in this situation because setting up and starting a zero duration tween is probably a good indicator something upstream has gone wrong. A tween by definition is something that occurs over time and if you pass in zero time something has gone wrong and the exception would alert you of the issue.
On the other hand can also see a zero duration tween just doing nothing and not even getting added to the tween list.
We'll see what Mr Carrierreierrere has to say on the matter since I can go either way.
Mike
On May 9, 2015, at 1:42 PM, Logan Knecht [email protected] wrote:
Ah, yeah. That was the route I ended up going, based on the initial solution provided here.
However, could you elaborate on the problem with the events people would be expecting to be fired. I'm afraid I'm not sure what you're communicating.
My perception of this issue is then when the value is being tweened is inclusive of the end value it should default to the end tween value and not something like "NaN".
Or if not, maybe just add something to error catch a 0f and instead pass Mathf.Epsilon instead of just allowing a bad value like that to continue propagating as a side effect/bug?
As a user of the code, I do not anticipate that by having a 0 duration on my tween that it'll affect my code in such a way. So, it seems like it should be fixed or handled more gracefully.
—
Reply to this email directly or view it on GitHub.
from gokit.
A year or two ago I rewrote a chunk of GoKit so that the Events that get fired on start/stop/iteration start/iteration stop were all reliable. Prior to that, you could have events that didn't fire, or fired inconsistently.
Taking the events out of the equation for a second: if you were generating the tweens dynamically based on a variety of inputs, it makes complete sense that sometimes you generate a tween that has a 0s duration. Every update we need to decide where we are along the timeline from start to finish, and update the tween appropriately. This math works out to something along the lines of (timeElapsed / totalDuration). With duration = 0s, we're dividing by zero, which is why you're getting NaN as a result for your values.
Lets say you wanted to move a cube from position x=0 to x=5, over the course of 0 seconds. On the first update, we're already passed the total duration, should the cube be at x=0 or x=5? From the way I designed this situation to work if the time minimum was Mathf.Epsilon (this is somewhat bringing back the events rework into the conversation), you would get one frame forced at x=0, and the next frame would be at x=5. Problem is with a duration of 0, my guess is that you'd want the tween to actually be at the END, where you were trying to tell the cube to go.
I don't have a ton of time immediately to resolve this -- but I'll reopen the issue and take a peek at how we might be able to handle the situation down the road. (Realistically, a week or two from now.)
Let's continue to have this conversation here if you have more to add, as it can give me something to think about in terms of how we'll solve this problem as best as possible.
from gokit.
Alright, thank you for the wonderful explanation and re-opening the issue.
from gokit.
so after some thought today, i've decided to force all tweens from now on to have a duration greater than 0. when we detect this case, we force the tween to have a duration of float.Epsilon, and throw a LogError to notify the issue. (Mike hasn't done any exceptions in GoKit, so I'm not going to start.)
I consider this resolved again, but definitely welcome conversation!
(see c7e9971)
from gokit.
Related Issues (20)
- GoDummyPathEditor "Shift Path to Start at Origin" seems to be incorrect
- AbstractGoTween.goTo does not update rotation HOT 1
- Android streaming GoSpline asset bug? HOT 2
- Built-in support for inserting functions into GoTweenCollections HOT 6
- Docs: link not working anymore (README.md) HOT 3
- Doesn't compile for Windows Phone 8 HOT 1
- What do you think about rearranging this repo so it could be a submodule or a subtree? HOT 5
- GoTween Incompatible with IL2CPP scripting backend HOT 14
- [Question] Player Camera on Path HOT 1
- Non functioning Tween when reusing a GoTween instance with modified TweenProperties HOT 5
- Canceling / destroying a tween collection HOT 4
- Changing the speed/during of a GoTween/GoTweenChain while it is playing HOT 2
- Is there a way to save all running tweens? HOT 1
- Need help with playBackwards() HOT 3
- How to check if Go has no animation running HOT 2
- [FEATURE REQUEST] ECS Support HOT 2
- [Request] Tween value without using property HOT 6
- Tweening Rotations Shortest Distance HOT 1
- Is there a way to queue Tweens by GoKit itself?
- Documentation installation (via github?) HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gokit.