← Back to list

pushback
by verekia
⚛️ React Three Fiber Game Dev Recipes
⭐ 17🍴 0📅 Jan 22, 2026
SKILL.md
name: pushback description: Make enemies flash white and rock back and forth when receiving damage.
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
- Store pushback direction (
dx,dy) and progress (0 to 1) - Use a triangle wave for back-and-forth motion:
t < 0.5 ? t * 2 : (1 - t) * 2 - Flash material color to white during pushback
- Reset to original position and color when complete
- Direction should be opposite to the damage source (player position)
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.
Score
Total Score
65/100
Based on repository quality metrics
✓SKILL.md
SKILL.mdファイルが含まれている
+20
✓LICENSE
ライセンスが設定されている
+10
○説明文
100文字以上の説明がある
0/10
○人気
GitHub Stars 100以上
0/15
✓最近の活動
1ヶ月以内に更新
+10
○フォーク
10回以上フォークされている
0/5
✓Issue管理
オープンIssueが50未満
+5
✓言語
プログラミング言語が設定されている
+5
✓タグ
1つ以上のタグが設定されている
+5
Reviews
💬
Reviews coming soon

