Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Crawl Animation Speed
- Terminology (not all the terms, but just ones that need explanation):
- AnimationRate = a value from 0 to 1 (or sometimes more) representing how close the animation is moving compared to full speed
- StickXRate = a value from [0.5 to 1] representing how fast the animation should move based on the control stick
- EndFrame = Last frame of animation (don't include the actual last frame!)
- AnimationDistance = The distance from the origin the animation moves to on the last frame
- (this also changes depending on the character's size multiplier!)
- CrawlSpeed = a character-and-direction specific value determining the maximum speed you should be moving
- FacingDirection = +1 for Right and -1 for Left
- SubactionID = The ID of the crawling animation
- //-----------------------
- Crawl_init_status //script_626: this code run when the animation first starts
- {
- CrawlSpeed = script_629()
- ForwardSpeed = HorizontalSpeed * FacingDirection
- initialAnimRate = 0
- if (ForwardSpeed >= 0)
- initialAnimRate = HorizontalSpeed/CrawlSpeed
- AnimationRate = initialAnimRate
- SubactionID = script_630()
- AnimationDistance = getTransNTranslateEndFrame(SubactionID)
- EndFrame = getEndFrame(SubactionID)
- if (abs(AnimationDistance) < 0.5)
- AnimationDistance = 20 //I don't know why they have this...
- TargetAnimationSpeed = abs( CrawlSpeed/(AnimationDistance/EndFrame) )
- }
- Crawl_exec_status //script_627: this code run on every frame
- {
- BaseCrawlAccelRatio = BaseWalkAccel/ForwardCrawlSpeed
- ScaledCrawlAccelRatio = StickXRate*(ScaledWalkAccel/ForwardCrawlSpeed)
- CrawlAccelRate = BaseCrawlAccelRatio + ScaledCrawlAccelRatio
- RateRatio = AnimationRate/StickXRate
- if (RateRatio > 0 and RateRatio < 1)
- CrawlAccelRate *= 0.5*(1-RateRatio)
- TractionRatio = Traction/ForwardCrawlSpeed
- if (AnimationRate + CrawlAccelRate > StickXRate)
- {
- CrawlAccelRate = -TractionRatio
- if (AnimationRate - CrawlAccelRate < StickXRate)
- CrawlAccelRate = StickXRate - AnimationRate
- }
- AnimationRate += CrawlAccelRate
- FrameSpeed = abs(AnimationRate*TargetAnimationSpeed)
- Set_Frame_Speed(FrameSpeed)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement