Advertisement
BenArthur_7

Crawl animation speed MSC

Mar 7th, 2018
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.16 KB | None | 0 0
  1. Crawl Animation Speed
  2.  
  3. Terminology (not all the terms, but just ones that need explanation):
  4.  
  5. AnimationRate = a value from 0 to 1 (or sometimes more) representing how close the animation is moving compared to full speed
  6. StickXRate = a value from [0.5 to 1] representing how fast the animation should move based on the control stick
  7. EndFrame = Last frame of animation (don't include the actual last frame!)
  8. AnimationDistance = The distance from the origin the animation moves to on the last frame
  9. (this also changes depending on the character's size multiplier!)
  10. CrawlSpeed = a character-and-direction specific value determining the maximum speed you should be moving
  11. FacingDirection = +1 for Right and -1 for Left
  12. SubactionID = The ID of the crawling animation
  13.  
  14. //-----------------------
  15.  
  16. Crawl_init_status //script_626: this code run when the animation first starts
  17. {
  18. CrawlSpeed = script_629()
  19. ForwardSpeed = HorizontalSpeed * FacingDirection
  20.  
  21. initialAnimRate = 0
  22. if (ForwardSpeed >= 0)
  23. initialAnimRate = HorizontalSpeed/CrawlSpeed
  24.  
  25. AnimationRate = initialAnimRate
  26.  
  27. SubactionID = script_630()
  28. AnimationDistance = getTransNTranslateEndFrame(SubactionID)
  29. EndFrame = getEndFrame(SubactionID)
  30.  
  31. if (abs(AnimationDistance) < 0.5)
  32. AnimationDistance = 20 //I don't know why they have this...
  33.  
  34. TargetAnimationSpeed = abs( CrawlSpeed/(AnimationDistance/EndFrame) )
  35. }
  36.  
  37. Crawl_exec_status //script_627: this code run on every frame
  38. {
  39. BaseCrawlAccelRatio = BaseWalkAccel/ForwardCrawlSpeed
  40. ScaledCrawlAccelRatio = StickXRate*(ScaledWalkAccel/ForwardCrawlSpeed)
  41. CrawlAccelRate = BaseCrawlAccelRatio + ScaledCrawlAccelRatio
  42.  
  43. RateRatio = AnimationRate/StickXRate
  44. if (RateRatio > 0 and RateRatio < 1)
  45. CrawlAccelRate *= 0.5*(1-RateRatio)
  46.  
  47. TractionRatio = Traction/ForwardCrawlSpeed
  48.  
  49. if (AnimationRate + CrawlAccelRate > StickXRate)
  50. {
  51. CrawlAccelRate = -TractionRatio
  52. if (AnimationRate - CrawlAccelRate < StickXRate)
  53. CrawlAccelRate = StickXRate - AnimationRate
  54. }
  55.  
  56. AnimationRate += CrawlAccelRate
  57.  
  58. FrameSpeed = abs(AnimationRate*TargetAnimationSpeed)
  59.  
  60. Set_Frame_Speed(FrameSpeed)
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement