大家好,我目前正在尝试实现激光武器的效果,但在 AGM 手法下面临一些课题,希望能得到各位的建议。
目前的尝试方法
PGM 侧的实现
用透明对象增加碰撞框 X 轴比例作为命中判定。
与敌人或墙壁碰撞时获取接触比例,并将该值反映到对象的 X 比例缩放中。
AGM 侧的实现
使用 RayCast2D 节点进行碰撞判定,通过 Line2D 节点绘制可视化的光束。
需要通过代码实现节点间的联动,但目前未能成功实现。
面临的问题
AGM 侧:无法理解 RayCast2D 与 Line2D 的联动代码,光束绘制位置无法正确呈现。
提问内容
能否提供 AGM 中 RayCast2D 与 Line2D 联动的代码示例?
恳请各位给予建议!,将上面的话翻译为日语和英语
//
皆さん、こんにちは。レーザー武器のエフェクト実装中に AGM 手法の課題に直面しています。ご助言をいただければ幸いです。
現在の取り組み方法
PGM 側の実装
- 透明オブジェクトで当たり判定の X 軸サイズを拡大
- 敵 / 壁との衝突時に接触割合を取得し、オブジェクトの X 軸スケールに反映
AGM 側の実装
- RayCast2D で衝突判定を行い、Line2D で視覚的な光線を描画
- ノード間のコード連携が必要だが、うまく実装できていない
直面している問題
AGM 側:RayCast2D と Line2D の連携コードが理解できず、光線の描画位置が正しく表示されない
質問内容
AGM で RayCast2D と Line2D を連携させるコード例を教えていただけますか?
宜しくお願いいたします。
//
Hello everyone, I’m facing issues with AGM approach while implementing laser weapon effects. Your advice is highly appreciated.
Current Attempts
PGM Implementation
- Using transparent objects to expand collision box X-axis size for hit detection
- Acquiring contact ratio on enemy/wall collision and reflecting it to object’s X-axis scale
AGM Implementation
- Using RayCast2D for collision detection and Line2D for visual beam rendering
- Struggling to implement code linkage between nodes
Issue Faced
AGM side: Can’t understand how to link RayCast2D with Line2D code, beam rendering position is incorrect
Question
Could you provide a code example for linking RayCast2D and Line2D in AGM?
Thank you in advance for your help!
1 Like
Have you taken a look at the Advanced Sample: Side-Scroller Mouse Shooter?
The Hookshot Chain, controlled by LineManager.gd, perhaps does kind of what you want to do?
1 Like
Hello! I’ve made an approximate laser bullet with keyframes in the animation. The steps are to use two keyframes to control the X-axis scale of the object on the right side of the center. When the object hits or collides with a wall, it switches to the next action. The next animation is set to loop, and the X-axis scale will inherit the previous one.
Is it working better now?
And to link nodes better, Godot uses what are called signals for passing data between nodes.
AGM also supports signals via the EmitSignal action in the visual script.
They’re a little complex to use, but between following the sample hookshot chain & use of signals you should be able to get the interplay you’re looking for.
If you’d like more advice, I would need to know what kind of animation effect you’re looking to make but can’t make in AGM. A visual sample (such as from an older game) would be useful.
簡単な横スクロールアクションゲームを作りたいだけなんです喵~。レーザー武器は普通に直線で使う予定です喵~。今困ってるのはダメージ数字の表示なんです喵~。公式のアドバイス、本当にありがとうございます喵~!明日は「シグナル(signals)」を使ってダメージ数字を表示してみるつもりです喵~!
I just want to make a simple side-scrolling action game meow~. Laser weapons are planned to be used in a straight line normally meow~. What’s bothering me now is the display of damage numbers meow~. I really appreciate the official advice meow~! Tomorrow, I plan to try using “signals” to display damage numbers meow~!
1 Like