STUNNING Animation w/ DOTween Unity async await UniTask

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
as you can see now it's much better hi today let's make a stunning animation using between and irritas in this tutorial I have even access form nature environment tropical item life and the product is from Kenneth I also use the twin and it does if you guys don't know how to save your tasks or use a switch to twin check out my video first let's create the entry point script we can you create the script and it's called animate scene you're gonna create a new game object we call it scene code whatever else you like I will add the component to the game object first let's animate the other size of the scenes we're gonna create and Transformer right and I will call it Auto object transform in Essa first we're gonna lock this component to add the game object to the array with no issues now we're gonna select all kinds of the objects we want to transform we're going to put it here and we're going to unlock the inspector now let's go back to our script we're gonna create a new Unitas function and I'm gonna call it animate after object for parameter I will ask the all right I'll call it object to anime and the cancellation token remember you always want to have your cancellation token on your tax we're gonna Loop 2z array of objects that we want to animate and then we're gonna scale this object using the twin I'm gonna pass the about the three to zero and I'm going to pass the duration which is 0.5 and I'm gonna use from a tension method which instead of tweeting to that value it will start from the given value then tweeting from the original one and I'm going to say is which have been the case of in our back if you guys just want to know how each type is matters work just check it out the instinct.net website it's gonna have the full details for you in here I want to have an is in Outback to have the bouncing effect which I think is kind of amazing now let's start we're gonna add a sync keyword here and I'm going to await animate after object I'm gonna party out of this extension from and then all the cancellation token I've already gets cancellation to Canon destroy now let's take a look at the editor I'll keep play as you can see is I'm going to start from the battles three the zero value which is zero zero zero and it gonna scale to the original value that we have but as you can see is a little bit more scatter at the beginning the reason is us is happy original scale and you jump back to zero and you're popping up to fix the results just disable all these options by setting the active to pause and then we're gonna activate when we're tweeting I'm gonna disable all this schema check and in here I'm gonna use game object dots selected two oh and here just remember to pass the cancellation token so you can see that is popping apps like an amazing engine effect now I will delay at the initial Point 0.5 seconds for you to have a better look at this are you await it with the EV task that delay and I'm gonna party time span from seconds and I'm gonna pass line 1.2 seconds with the cancellation tokens acid cancellation took it let's run you can see it's already popped up quite nicely however as you can see in here all the objects that were animated it's all popping up in the same time I want this kind of objects to popping up some kind of in some kind of sequence which kind of cool let's change this so in this follow I'm gonna wait for 0.1 seconds then I'm going to pass the cancellation token at the cancellation token so the Logics behind here is US after each objects getting scale is gonna delay a little bit and then after the delay the next object will be scale and it will create some kind of motion animations which is going to make sure game more responsive let's take a look as you can see it's pop up and then all the Gable checks has been initials and scale before we continue let's make sure you smash the like button and hit the Subscribe button by doing so you'll have the channel grows and make sure that's knowledge is go to everyone thank you but you can see that our solution is not yet perfect the tower rather in these positions have been spawned quite slow and then all the other objects have been popping up I will show you again as you can see there is a Scuttle after this objects has been popping up to fix this issues we gonna use invertise that's when O Let's refractor is we're gonna select this week higher code and I'm gonna use reflector and I'm going to give it a transmitted and I'm going to create animate delay last night and instead of returning on tasks I'm going to return on any task I'm also gonna pass it Tom instead of the integer I also gonna pass a single object only so instead of you passing objects to anime I'm gonna pass a single one and I'm gonna move this delimiters on top of that so we will delay first and then we're gonna twinning the object and instead of twinning from oh sorry instead of waiting for 0.1 seconds I'm gonna pass the time right here in this animate Ultra objects first I'm going to create an imitas array let's go with task equal new Unitas and I'm gonna pass it length which equal to the objects to animate all right I'm still gonna look through the object to animate array but instead of awaiting the methods to be finished I'm gonna add this to the list equal animate delay and I'm gonna pass the object to animate all right the cancellation to again the times which is going to be I multiply by 0.1 so its object is gonna it's gonna be popped up after the previous one 0.1 seconds then I'm gonna oh wait in with us when o and I'm gonna pass it out right there you go if you guys want to learn more about how to use if it has venue when working with the twin please check out my video The Links will be down in the descriptions now let's run it in the editor as you can see we already fixed the issues as we mentioned mentions the all the objects in here have been spawned simultaneously in sequence now after we finish animating the outer images let's get in starts with the inner one I'm gonna correct another array let's go ahead inner object transform and then I'm going to do it another a cementus which gonna return Unitas let's go ahead animate inner object I'm gonna pass the option to animate Transformer and then most important knee cancellation token foreign then I'm gonna scale all these objects using between there you go I will say oh wait animate in object pass in object on transform and the cancellation token on this chart in this time I will just reflect up by extracting this calculation token as a variable replace two occurrences here there you go as you can see it's quite nicely now initiator same as the outer objects first we're going to lock the inspector then we are gonna beside all the gamer check this is all right and we're gonna disable it so that's we can have the popping up if it's quite slide now let's run oh I forget to activate so objects so let's change back in my code in here I'm gonna selective this object and I'm gonna pass C objective animate here kind of forget about it huh now let's play as you can see we have already have an amazing effect here but if you check any console tab you can see that the Box Collider does not support negative skill or size warning in here so what is the reasons the reason for this is our is function in here we use e is dot in our back which as you can see on the diagram is first it's gonna scale down below zero and then it's gonna pop up and down so because it went out below zero the boss collider has the values of negative so it should display the warning Force to make the pointing ones let's use another is function as you is Outback in here I will use is Outback the display we can see this the animations as have been displayed with no warning have been shoulder another thing that will be need to be improved as you can see that's the tense right here is actually immersed quite early because we want all the outer objects to be popping up then the inner objects that we merge so the fact that it's emerged sooner than we expected is not what we want I will show you again as you can see all the tests right here are popping up before the wooden bridge the reasons for that is in our animate is a delayed matters we scale the objects using the twin but we have an await for it to be finished before we're running this Live code one way to fix this is we're gonna add the Boolean parameter score is last object and then we're gonna check if this is the last object we're gonna avoid for it and if it's not we're gonna execute it normally then in here I'm gonna pass I equal object dot animate dot length minus one to make sure it is a large object or not if you guys have another approach to these issues please comment down below now let's take a look at the editor where we play we will see that after all the other scenes after objects on the scene has been immersed the in the sense inside here started popping up and that's exactly what we want now what we will do is we're gonna initialize that ship over there and then move the chip from the earth the original position to do that first let's guess the shape object correct transform and I'm going to record actually transfer then we also are gonna need the start position then another thing is we're gonna start the ship's current position and then after is popping up we're gonna move the position to the current position as we already saved I will call it chapter 3. current shift position I'm going to create another Unitas a c method I will call it animate ship we will transform to this strip and of course the cancellation total first let's settle shape object to be true oh sorry first let's say the currency position to the C position then we're gonna move the position of the ship to the start composition then after that we will activate the ship now we will use between new scale and I'm gonna pass only code right here there you go and I'm gonna await that and let's set the ease to in our back after the soup have been scale or popping up I will move the ship to the starting point position I will pass the current shift position with duration is uh 0.4 I think that's okay and I'm gonna copy all the current part here and I think that's good to go we will use a weight animation and I'm gonna pass the description from and the calculation token with strong let's see in the editor I'm gonna pass the ship here and the start position I'm gonna disable the ship and let's play you can see that's after all the other scenes has been initialized and then in the scene the ship have been immersed and is moved back to the original position but as you can see it's moved quite fast now let's slow down a little bit I'm gonna change this form 0.7 let's see as you can see now it's much better or the other scene and the inner scenes have been scale as we expected and then the ship going to emerge from C and move to that position another cool thing about a scene OS approach to this kind of Animation I want to show you is you can actually inject short code between those animation and you're going to do this in a clean way let's take a look I will pass a new buy text for demonstration only let's go attack and then I'm going to create a function called says type I'm given value assets parameter the text that text going to be equal to stated plus value now after we animate the auto objects we're gonna set the text to initial sync other option similarly we will set the text to to be inner object and move ship let's save it and go to Unity I will pass my UI text to the reference let's save it and run or objects let me scale as you can see the status has show us the status of the animation what we're doing in the screen you will see us the text is moving quite fast so let's add something like code between it to make sure that we cease better await if it has delay I'm gonna pass slide 0.4 second sorry times then five seconds and I'm gonna pass 0.4 seconds the same with the inner object now let's see we're gonna hit play after that yeah that's amazing you will see that with a single weight approach and I'm going to do this with any task it is quite simple and elegant for you to write those code and without any callback methods or chaining any coroutine to each other just plain text simple write that that is the end of my video please like And subscribe to the channel thank you for watching
Info
Channel: NotJustUnity
Views: 4,869
Rating: undefined out of 5
Keywords: animation, Unity UniTask, Asynchronous Programming, C# Coroutine Alternative, Task Management, Performance Optimization, Unity Plugin, Multithreading, Async Await, Concurrency, Unity Development, Game Programming, Real-time Processing, Programming Paradigm, Code Efficiency, Resource Management, Unity Asset Store, Unity Game Engine, Programming Languages, Code Optimization, Unity Scripting, Dotween, Unity Dotween, Tweening, unity, game development, tutorial, dotween
Id: NyOjfb1SfY4
Channel Id: undefined
Length: 27min 43sec (1663 seconds)
Published: Wed May 24 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.