Procedural Animation in 5 Minutes | devlog 1

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
for aesthetic purposes i will refer to two practical groupings of legs ankle legs and knee legs we don't have enough time in this video to get an in-depth understanding of inverse kinematics so use this function and treat it like a black box length one refers to the upper leg length length 2 refers to the lower leg length if you don't quite understand vectors just remember that a vector represents an x and y value the end effector is a vector representing the position of the hand or foot of the limb in this function we're only concerned with the end effector's local position the difference between a global and local position is important to understand consider the following if you wanted to use inverse kinematics to estimate where my right knee would be located the position of my hip and right foot are relevant so if i only told you that my foot was located on mount vesuvius that wouldn't be very helpful however if i told you that my foot was located half a foot downwards and half a foot to the side you could at least infer a couple of configurations my light could find itself in our ik function is only concerned with the local position of the foot so subtract the hips global position from the foot's global position to find the relative local position when your limb stretches further than the specified segment lengths you might get a not a number error in this case just set the relative elbow angle value to zero there are two relevant angles for this situation the relative elbow angle and the end effector angle before you convert your angle into an elbow position you'll need to add these two together if you want a knee leg use a positive relative elbow angle if you want an ankle leg use a negative one or vice versa depending on your application my function returns a vector but if you can't work with vectors you could just as easily return an angle and pass x and y values into the function instead also since my function returns a local value you want to reconvert to global space by adding the return value onto the global position of the shoulder or hip now you should have the global position of the hip elbow and foot and you can simply draw lines between them the rest of the video gets more complex so the code implementation details are more so up to you we have a character named bob with two legs bob exists in plane or 2d space so he's drawn from a side view each foot has a target position which continually hovers some negative or positive horizontal distance in front of bob this target position is always on the ground each foot also has a lerp position representing where the feet are continually moving towards if the distance of any of bob's feet from the hip exceeds the sum of the upper and lower leg lengths then that foot's lerp position will be set to its target position on every frame we interpolate between the current position and alert position by some constant value using the regular foot position as our drawing position give bob a way to move left or right and you should see bob periodically and awkwardly sliding his feet in unison this method is very simple but works best for top-down perspectives the following gif is where i first learned of this method and it was made by game maker studio developer rujic the gif itself is well made and threatens to make my explanation obsolete see for yourself [Music] rujic's more recent work looks to me to be using the same method only with a different ik solution and being in 3d everything he's doing looks amazing but i think he can do even better the issues with this method are as follows individual limb pairings will often move in exact or close timing with one another this is an issue in planar applications and even top down it leads to weird gaits that do not fit the velocity of the character characters don't lift up their feet leading to a shuffling animation the foot movement is unnaturally abrupt and instantaneous manufacturing momentum out of seemingly nowhere the method outlined in this video has these three issues to deal with not to mention that if speeds vary then multiple target distances would need to be defined for movement to look natural in my next video i'll solve all of these issues using a separate method for now we can try to resolve the first issue by creating sort of a hybrid method this will at least make this applicable to planar characters such as bob who otherwise look odd if you can successfully implement everything detailed in this video then this is a good exercise in preparation for the next video instead of changing the alert position based on the distance of the feet create a boolean or integer value to represent which foot is currently selected then create a timer which periodically resets every second or so each time you reset the timer change the alert position of the currently selected foot and select the other foot with the right time value the feet should alternate instead of moving in sync i don't recommend doing this but if you want to give yourself a headache you can define separate step distance and step period values for different speeds and interpolate between them with a character whose speed varies if you want to understand the theory behind locomotion you could try to write a function to procedurally redefine these parameters using only velocity and limb length values as an input if you have any issues or questions relating to this video or the implementation of the method feel free to leave a comment or join my discord where i'll be sure to help otherwise if you insist on working independently and are running into issues relating to inverse kinematics i have a slower paced ik video as a resource next video i'll get into the theory of animal locomotion and outline a superior technique you
Info
Channel: Benjamin Blodgett
Views: 49,326
Rating: undefined out of 5
Keywords: indie, indiedev, gamedev, procani, procedural animation, spore, rainworld
Id: PcpkBzcRdSU
Channel Id: undefined
Length: 5min 25sec (325 seconds)
Published: Sun May 01 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.