用Claude Code生成ChatGPT提示词制作2D游戏背景
キャラに合う2D背景が見つからないので、Claude Codeにプロンプトを書かせてChatGPTで一から作った
原文分享了利用Claude Code辅助编写ChatGPT提示词以生成游戏背景的具体工作流与调优细节。
角色合适的2D背景找不到,于是让Claude Code写提示词,再用ChatGPT从零制作
我不会写游戏程序。通过用日语指示AI,正在Unity 6中开发2D动作游戏。
本文是上一篇文章的续篇。
在2D动画上三次受挫后,最终落脚于“AI视频→Python精灵化”
第二个角色进展迅速
由于第一个角色已经确立了动作制作方法,第二个角色的素材准备相当快。
为什么需要背景
当两个角色就位后,接下来就需要确认它们在“游戏画面中看起来如何”。
- 透明部分是否干净地去除掉了
- 角色的轮廓是否在背景上显得突兀
- 角色的大小比例是否合适
为了确认这一点,需要创建背景并准备敌人角色。
敌人角色暂时放置了之前制作其他游戏时购买的付费素材。虽然尺寸并不完全匹配,但用于查看显示效果已经足够。
在寻找素材时未能找到
背景方面,我查看了手头的资产和素材网站。然而,很难找到与角色氛围相符的内容,因此我决定从头准备。
步骤:使用 Claude Code 创建提示词,并通过 ChatGPT 生成
流程如下。
- 向 Claude Code 传达舞台的意象和角色的特征,让其编写用于 ChatGPT 的提示词
- 在 ChatGPT 中,在同一聊天窗口中按从上到下的顺序生成五种图层
- 导入Unity,将角色与VFX叠加以进行确认
制作的是平野(草原)场景。图层共有以下5种类型:
| 順番 | 图层 | 役割 |
|---|---|---|
| 1 | 完成效果图 | 图案与光照基准(不用于游戏) |
| 2 | 遠景 | 天空、山脉、朦胧的山丘 |
| 3 | 中景 | 丘、木、石垣、风车、遗迹 |
| 4 | 接地面 | 角色站立的地板(横向瓷砖) |
| 5 | 前景 | 草丛、古树、石柱等小物件各一个 |
Claude Code 调整了四个要点
在撰写提示词时,Claude Code 有意加入了以下四点:
| 調整 | 理由 |
|---|---|
| 不输入作品名称 | 如果点明具体作品的名字,设计风格就会偏向那部作品。由于这是用于产品的素材,因此用“带有风车和石砌建筑的欧式田园牧歌草原”这样的特征来指定。 |
| 抑制绿色的饱和度 | 主人公角色的衣服是绿色的,所以会融入背景中 |
| 避开傍晚景色 | 因为金色的VFX和头发会与背景融为一体,所以改成朦胧的晨光。 |
| 把天空调暗 | 如果是白色背景,加法合成的VFX会过曝 |
由于角色和特效是提前制作的,因此从一开始就设定了“背景不能干扰角色和VFX”这一条件。
1. 完成图像(全文)
附上主角角色的待机图片进行生成。这是绘制风格的基准,会反复修改直到满意为止。
Using the attached character only as a reference for the art style, paint a background for a 2D side-scrolling action game. Do not draw the character or any people.
Scene: a vast, windy European-style pastoral grassland in a fantasy world. Gently rolling meadows, scattered clusters of broadleaf trees, a low stone wall, a distant wooden windmill, old stone ruins, and far blue mountains under a soft overcast morning sky.
View: pure side-on view, like a stage in a 2D side-scroller. The ground is flat and horizontal across the lower quarter of the image, with no road leading into the distance and no high-angle perspective.
Style: high-end hand-painted 2D game art, rich painterly brushwork, semi-realistic fantasy, matching the attached image.
Color and value: muted, slightly desaturated sage and olive greens, dusty blues, soft grays. Overall mid-to-dark values with low contrast, so that a bright character and glowing visual effects stand out. No pure white areas. No golden sunset light.
Wide landscape format. No text, logo, UI, or watermark.
专栏:“为什么需要完成图像?”
我不理解为什么要特意制作一张不直接用于游戏的图片,于是向Claude Code请教了。因为我不想完全交给AI处理,而是想先了解原因并信服后再继续推进。答案的要点如下:
- 完成图的概念是,通过统一各层图案与光线的共同标准来确保一致性,这些标准不会直接用于游戏
- レイヤーを別々に生成すると、次のずれが出やすい
- 光线方向不一致(远景从左方照射,中景从右方照射)
- 每层的草色和空气感不同
- 笔触风格不统一(远景为水彩风格,而接地面则为写实风格)
- 山、树木和建筑的氛围显得杂乱无章
- 单张看时效果不错,但叠加后却像拼贴了不同的画作
- 方向性を先确认也起着这样的作用。如果等到所有图层都完成后才发现问题,就需要全部重做;但如果是在完成构思阶段,只需修改一张图即可。
- 并非必须如此,也可以以远景为基准。不过由于远景中不会包含树木、建筑物和地面等元素,因此将所有要素都包含在一张图中的完成构思作为基准更为可靠。
在充分理解后,我决定从完成构思开始制作。
2. 遠景(抜粋)
Based on the previous image, paint only the farthest background layer for a parallax side-scroller. Include only: an overcast morning sky with soft layered clouds, distant blue-gray mountains, and faint rolling hills fading into atmospheric haze on the horizon. Do not include trees, buildings, windmills, ground details, or people.
...
The left and right edges must connect seamlessly when tiled horizontally.
3. 中景(抜粋)
Based on the first image, paint only the middle background layer for a parallax side-scroller. Include: gently rolling grass hills, clusters of broadleaf trees, a low stone wall, a small wooden windmill, and a few old stone ruins, spaced unevenly across the width with gaps between them.
...
Everything above the hills and trees must be fully transparent. The bottom of the image must be solid grass hill all the way across, because the ground layer will cover it.
当无法透明处理时,替换为下一句文字,使其以洋红色背景显示,之后再去除背景。
Use a perfectly flat solid magenta background (#FF00FF) instead of transparency, with no shadow or gradient on the background.
4. 接地面(全文)
这是角色所站立的平面。如果上面的线条不直,角色看起来就会像是漂浮或嵌入其中。
Based on the first image, paint only a horizontal ground strip for a 2D side-scroller. Pure side-on cross-section view. The top surface is a perfectly straight, level horizontal line across the entire width, with short grass tufts slightly overlapping that line. Below it are grass-covered soil, small embedded stones, and dark earth, getting darker toward the bottom of the image. No perspective and no visible ground plane receding into the distance. No hills, slopes, holes, trees, buildings, or people. Grass and stone detail should be evenly spread, with no eye-catching feature that would look repetitive when tiled. Same art style. Muted sage and olive greens with dark brown earth, mid-to-dark values. Everything above the grass tufts must be fully transparent. The left and right edges must connect seamlessly when tiled horizontally. Wide landscape format, PNG with transparent background. No text, logo, or watermark.
5. 前景(抜粋)
[ITEM] 逐个替换并生成。
Based on the first image, paint a single foreground prop for a 2D side-scroller: [ITEM]. Show only this one object, complete and not cut off, in pure side view, with its base on a straight horizontal line.
...
No ground, cast shadow, scenery, or people. PNG with transparent background.
替换的ITEM共有5种:草丛、蒲公英与野花、古树、长满苔藓的石柱、木栅栏。






效果不佳时的补充指令
| 症状 | 补充指令 |
|---|---|
| 过于明亮 | 使整张图像变暗并降低对比度。移除所有近白色区域。 |
| 颜色过于鲜艳 | 将绿色饱和度降低约30%,偏向鼠尾草绿和橄榄绿。 |
| 略显俯视 | 使用完全平坦的侧视图,地平线保持水平。不要透视。 |
| 地面倾斜 | 将地面顶部边缘做成一条完全笔直的水平线。 |
接缝的修补方法
即使指示“无缝连接”,也常常无法完全连接。
- 在图像编辑软件中,将图像横向移动一半(使接缝位于中央)
- 附加给ChatGPT,并请求如下操作
Repaint only the vertical seam in the center so that the left and right sides connect naturally. Keep everything else, the size, and the style exactly the same.
如果整体发生较大变化,则将中央部分合成回原图。
虽然Claude Code也提供了此步骤,但本次无需修正接缝即可直接使用。
最初使用3张就足够了
最初制作完成效果图、远景、接地面这3张就足够了。在Unity中把角色和特效叠加起来确认之后,再推进到中景、前景,就能减少返工。
虽然这个提示词连 Claude Code 自己也写着“还没在 ChatGPT 上试过,所以需要调整”,但实际上几乎一次就生成了可用的图。
結果
与角色的搭配没有问题,总体上很满意。通过沿用手顺,似乎也能准备其他舞台。
总结
- 因为角色制作方法已经确定,所以第2个角色很快就准备好了
- 要确认透明效果、描边和尺寸感,需要背景和敌方角色
- 找不到与氛围相符的背景素材,于是从零开始制作
- 让 Claude Code 编写提示词,并在 ChatGPT 中于同一聊天窗口内依次生成了五种图层
- 为确保背景不干扰角色和特效,从一开始就指定了饱和度、光线和天空的亮度
- 以完成构想为基准,使各图层的画风和光线保持一致。在询问 AI 理由并感到信服后才继续推进
- 按照相同步骤,似乎也能制作其他场景
链接
- 上一篇文章:在2D动画中三次受挫后,最终选择“AI视频→用Python制作精灵图”
- 2D动画部分的视频:https://youtu.be/Qtvfq5eEp0M
- 开发中的3D游戏《勇者小队的苦劳人》(itch.io):https://subaru33jp.itch.io/the-hero-partys-babysitter
- 前作の2Dゲーム「Princess Vanguard」(ブラウザで遊べます)
- itch.io:https://subaru33jp.itch.io/princess-vanguard
- ふりーむ(Free Game Mugen):https://freegame-mugen.jp/roleplaying/game_15623.html
- 演示视频:https://youtu.be/J8aooF3N8AA
- X(@PuddingAthlete)
前往点赞用户列表
0
注册新用户,更便捷地使用 Qiita
- 获取符合您需求的文章
- 高效回顾有用信息
- 可使用深色主题
来源:Qiita · Unity 开发社区 · qiita.com




