How to Implement Laser Weapon with AGM: Code Example for RayCast2D and Line2D Linkage

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.

I just want to make a simple side-scrolling action game, meow~. I plan to use laser weapons in a straight line normally, meow~. What I’m struggling with right now is displaying damage numbers, meow~. Thank you so much for the official advice, meow~! Tomorrow, I’m going to try displaying damage numbers using “signals”, meow~!

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