Im trying to create some kind of a bullet hell game, but first I want to be able to create a projectile that will be pretty flexible. Here is my projectile script atm:
var dir = Vector2(1, 1)
export var bullet_speed = 200
self.position += dir * delta * bullet_speed
func create_bullet(direction, spawnpos, offsetX = 0, offsetY = 0, ignoreoffset = false):
spawnpos.x += offsetX
spawnpos.y += offsetY
self.position = spawnpos
dir = direction
And my character is currently using this method to "fire":
var bullet = Bullet.instance()
get_global_mouse_position().x - self.position.x,
get_global_mouse_position().y - self.position.y).normalized(),
self.position, 50, 50)
The problem is, once I pass the parameters "50, 50" to the offset, the offset is "fixed" to the character, but I needed the offset to be relative to the position the player is looking, to make it spawn from a different place in case a different creature is shooting.
For example if my character uses like 2 cannons, I would need to fire it slightly offset to the left and right to match the sprite, but the "offset" would need to rotate with the player.
I know that my create_bullet method, I would need to make something else than adding offset to spawnpos, but since its math based, I dont know how to solve this.