#How to setup nodes to create different bullet patterns

1 messages · Page 1 of 1 (latest)

fresh ridge
#

There are many ways of making this work depending on how you want every little thing to work but you can try looking into State Machines.
https://www.youtube.com/watch?v=ow_Lum-Agbs

In this video we'll walk though the setup and creation of a Finite State Machine (FSM) in Godot 4.

Finite State Machines are incredibly useful for managing simple states and transitioning between them. For this video we will look at an enemy with the states of wandering, following, and attacking. Then, we'll build the wander and follow states t...

▶ Play video
obsidian idol
#

State machines seems rather overkill?

fresh ridge
#

I don't think so?
Either way, you don't really have to have a statemachine, but you can approach guns with a similar idea where a gun can be a node

#

the ship sends the shoot signal to whatever gun is equipped and the gun has the behaviour of what it should do when shot

#

Or the ship can have all the weapons at any time, and you can just swap which one is active

obsidian idol
#

Just so I understand, I would have to swap out the nodes/scripts ( i dont want the weapons to always be attached to the ship )

fresh ridge
#

You can have references to the nodes in the script like
var weapon_a = preload("res://..wherever the weapon scene is")
and then you would add a weapon by doing
var weapon = weapon_a.instantiate()
add_child(weapon)
and when you want to remove it
weapon.queue_free()

#

Also if weapons have no visual changes, just different behaviours, you can just have them on the ship all the time, have a variable that points to the currently active weapon, and only call its fire function