Skip to content

How to create combo fighting mechanics with timing in Scratch

💡 Want to create advanced combat systems and professional game mechanics? 🚀 Get Help Now

CA

CombatCoder_Alex

Posted on July 20, 2025 • Advanced

⚔️ Need help with combo fighting system!

Hey everyone! I’m working on a fighting game with frame-by-frame animation and I want to create a sophisticated combo system like in battlegrounds games (think Strongest Battlegrounds on Roblox).

Here’s what I want to achieve:

  • 4-hit combo sequence: Left jab → Right cross → Special move → Right uppercut
  • Timing-based progression: If you click soon after the first attack, it continues to the next in sequence
  • Combo reset: If you wait too long, it resets back to the first attack
  • No infinite loops: The combo should have a clear end and proper state management

I know I could just make costumes with delays, but I want the dynamic timing system where the combo only progresses if you click within the right time window. How do I track the time between attacks and manage the sequence state properly? 🤔

TM

TimingMaster_Jordan

Replied 6 hours later • ⭐ Best Answer

Excellent question @CombatCoder_Alex! Creating a proper combo system with timing is all about tracking time and managing state. Let me break down the complete solution for you.

🎯 Understanding Combo Timing Systems

A good combo system needs to track three key things: when the last attack happened, what stage of the combo we’re on, and whether enough time has passed to break the combo:

flowchart TD A[Attack Button Pressed] --> B[Check Time Since Last Attack] B --> C{Within Combo Window?} C -->|Yes| D[Continue Combo Sequence] C -->|No| E[Reset to First Attack] D --> F[Increment Combo Stage] F --> G{Max Combo Reached?} G -->|Yes| H[Reset Combo] G -->|No| I[Execute Current Attack] E --> J[Set Combo Stage to 1] J --> I I --> K[Update Last Attack Time] K --> L[Play Animation] style A fill:#e1f5fe style D fill:#e8f5e8 style E fill:#fff3e0 style H fill:#ffebee

⚡ Solution 1: Basic Combo System with Timing

Here’s the core combo system using precise timing:

    // Initialize combo system
when flag clicked
set [combo stage v] to [0]
set [last attack time v] to [0]
set [combo window v] to [1.5] // 1.5 seconds to continue combo
set [max combo attacks v] to [4]

// Main attack handler
when [space v] key pressed
// Calculate time since last attack
set [time since last v] to ((timer) - (last attack time))

// Check if we're within combo window
if <<(time since last) < (combo window)> and <(combo stage) < (max combo attacks)>> then
// Continue combo
change [combo stage v] by [1]
else
// Reset combo
set [combo stage v] to [1]
end

// Execute the attack based on combo stage
if <(combo stage) = [1]> then
broadcast [left jab v]
end
if <(combo stage) = [2]> then
broadcast [right cross v]
end
if <(combo stage) = [3]> then
broadcast [special move v]
end
if <(combo stage) = [4]> then
broadcast [right uppercut v]
set [combo stage v] to [0] // Reset after final attack
end

// Update last attack time
set [last attack time v] to (timer)
  

🎮 Solution 2: Enhanced Combo System with Visual Feedback

Add visual indicators and sound effects for better player feedback:

    // Enhanced combo system with feedback
define execute combo attack (stage)
if <(stage) = [1]> then
// Left Jab
switch costume to [jab1 v]
move [10] steps
play sound [punch1 v]
set [combo indicator v] to [●○○○]
end

if <(stage) = [2]> then
// Right Cross
switch costume to [cross1 v]
move [15] steps
play sound [punch2 v]
set [combo indicator v] to [●●○○]
end

if <(stage) = [3]> then
// Special Move
switch costume to [special1 v]
move [20] steps
play sound [special v]
set [combo indicator v] to [●●●○]
set [color v] effect to [25] // Visual effect
end

if <(stage) = [4]> then
// Right Uppercut (Finisher)
switch costume to [uppercut1 v]
change y by [30]
play sound [finisher v]
set [combo indicator v] to [●●●●]
set [brightness v] effect to [50]
wait [0.5] seconds
set [combo indicator v] to [○○○○]
clear graphic effects
end

// Animation sequence for each attack
repeat [5] // Frame animation
next costume
wait [0.1] seconds
end
switch costume to [idle v]
  

🔄 Solution 3: Advanced State Management

For more complex combo systems with branching paths:

    // Advanced combo state management
when flag clicked
set [combo state v] to [idle]
set [combo timer v] to [0]
set [combo damage v] to [0]

// Combo state machine
forever
if <(combo state) = [attacking]> then
change [combo timer v] by [1]

// Check for combo timeout
if <(combo timer) > [90]> then // 1.5 seconds at 60fps
set [combo state v] to [idle]
set [combo stage v] to [0]
set [combo timer v] to [0]
broadcast [combo broken v]
end
end
end

// Attack input handler with state management
when [space v] key pressed
if <(combo state) = [idle]> then
// Start new combo
set [combo state v] to [attacking]
set [combo stage v] to [1]
set [combo timer v] to [0]
execute combo attack [1]
else
if <(combo state) = [attacking]> then
// Continue combo if within window
if <(combo timer) < [45]> then // 0.75 second window
if <(combo stage) < [4]> then
change [combo stage v] by [1]
set [combo timer v] to [0]
execute combo attack (combo stage)
else
// Combo complete
set [combo state v] to [idle]
set [combo stage v] to [0]
broadcast [combo complete v]
end
end
end
end
  

💥 Solution 4: Damage and Effects System

Add damage scaling and special effects for complete combat feel:

    // Damage and effects system
define calculate combo damage (stage)
if <(stage) = [1]> then
set [attack damage v] to [10] // Base damage
end
if <(stage) = [2]> then
set [attack damage v] to [15] // Increased damage
end
if <(stage) = [3]> then
set [attack damage v] to [25] // Special move bonus
end
if <(stage) = [4]> then
set [attack damage v] to [40] // Finisher damage
create clone of [explosion effect v]
end

// Apply combo multiplier
set [total damage v] to ((attack damage) * (1 + ((combo stage) * 0.2)))
change [combo damage v] by (total damage)

// Visual feedback for damage
create clone of [damage number v]
set [damage text v] to (total damage)

// Screen shake for impact
if <(combo stage) > [2]> then
repeat [5]
change x by (pick random [-3] to [3])
change y by (pick random [-3] to [3])
wait [0.05] seconds
end
go to x: [0] y: [0]
end
  

🎨 Solution 5: Complete Animation System

Smooth frame-by-frame animation with proper timing:

    // Complete animation system
define play attack animation (attack_type) (frames)
set [animation playing v] to [true]
set [current frame v] to [1]

repeat (frames)
switch costume to (join (attack_type) (current frame))

// Different timing for different attacks
if <(attack_type) = [jab]> then
wait [0.08] seconds // Fast jab
end
if <(attack_type) = [cross]> then
wait [0.12] seconds // Medium cross
end
if <(attack_type) = [special]> then
wait [0.15] seconds // Slower special
end
if <(attack_type) = [uppercut]> then
wait [0.2] seconds // Slow powerful uppercut
end

change [current frame v] by [1]
end

// Return to idle
switch costume to [idle v]
set [animation playing v] to [false]

// Allow next input
if <(combo stage) < [4]> then
set [can attack v] to [true]
end
  

The key is using the timer to track precise timing and managing the combo state properly. This creates that satisfying battlegrounds-style combat feel! ⚔️

CA

CombatCoder_Alex

Replied 30 minutes later

@TimingMaster_Jordan This is absolutely incredible! 🤩

I implemented the basic timing system first and it works perfectly! The combo flows so smoothly now and the timing window feels just right. The visual feedback with the combo indicators makes it feel so professional.

I’m definitely going to add the damage scaling and screen shake effects next - this is exactly what I was looking for. Thank you so much for the detailed breakdown! 🙏

AG

AnimationGuru_Sarah

Replied 2 hours later

Amazing solution @TimingMaster_Jordan! 👏 I’d like to add some animation tips to make the combos even more polished:

  • Anticipation frames: Add 1-2 frames before the actual attack for better visual flow
  • Recovery frames: Include frames after the attack where the player can’t act yet
  • Hit pause: Briefly freeze the animation on impact for more satisfying hits
  • Particle effects: Add impact sparks or dust clouds for each hit

These small details make the difference between a good combo system and a professional one! 🎮

BG

BattlegroundsPro_Mike

Replied 1 hour later

As someone who’s studied battlegrounds games extensively, this solution is spot-on! 🎯

One additional tip: consider adding “combo breakers” - special defensive moves that can interrupt enemy combos. This adds strategic depth and prevents infinite combo loops in PvP scenarios.

Also, for mobile compatibility, you might want to add touch controls alongside keyboard inputs. The timing system works perfectly with both! 📱

VB

Vibelf_Community

Pinned Message • Moderator

⚔️ Master Advanced Combat Systems!

Fantastic discussion on combo mechanics and timing systems! For those ready to create professional fighting games and advanced combat systems, our community offers:

  • 🥊 Advanced combat mechanics and state machines
  • ⏱️ Precise timing systems and input buffering
  • 🎬 Professional animation techniques and frame data
  • 🎮 Complete game balancing and playtesting guidance

📚 Related Discussions

Ready to create professional-quality combat systems? Get personalized guidance from our expert game development tutors in the Vibelf app!