Pushback

From verekia/r3f-gamedev · View interactive version

Pushback is an AI agent skill from the GitHub repository verekia/r3f-gamedev. Make enemies flash white and rock back and forth when receiving damage.

How to use this skill

Skill file

Pushback

Make enemies flash white and rock back and forth when receiving damage.

Technique

Track pushback state with a direction vector and progress value. In useFrame, interpolate the position along the pushback direction using a back-and-forth curve, and change the material color to white during the effect.

Key Concepts

Usage

const pushbackRef = useRef<{ dx: number; dy: number } | null>(null)
const pushbackProgress = useRef(0)

useFrame((_, delta) => {
  if (pushbackRef.current) {
    pushbackProgress.current += delta * 8
    material.color.set('white')

    const t = pushbackProgress.current
    const offset = t < 0.5 ? t * 2 : (1 - t) * 2
    mesh.position.x = baseX + pushbackRef.current.dx * offset
  }
})

This skill is part of verekia's **r3f-gamedev**.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.