// Start is called before the first frame update void Start() { // Math calculation acceleration // s = distance // a = acceleration // t = time // s = 1 / 2 at² // a = 2s / t² acceleration = (2f * maxSpeed) / Mathf.Pow(timeToMaxSpeed, 2); minSpeedThreshold = acceleration / Application.targetFrameRate * 2f; movementController = GetComponent <MovementController>(); anim = GetComponent <Animator>(); spriteRenderer = GetComponent <SpriteRenderer>(); animationTimes = GetComponent <AnimationsTimes>(); // Math calculation for gravity and jumpForce gravity = -(2 * jumpHeight) / Mathf.Pow(timeToMaxJump, 2); jumpForce = Mathf.Abs(gravity) * timeToMaxJump; maxFallingSpeed = -jumpForce; if (animationByParameters) { UpdateAnimation = UpdateAnimationByParameters; } else { UpdateAnimation = UpdateAnimationByCode; } }
// Start is called before the first frame update void Start() { dangerous = true; movementController = GetComponent <MovementController>(); spriteRenderer = GetComponent <SpriteRenderer>(); anim = GetComponent <Animator>(); animationTimes = GetComponent <AnimationsTimes>(); StartFacing(); }