- Edited
im trying to make a bullet hell spread based on the node's rotation and convert it to vector however when i try to increase the node's rotation using the customRot it always stays at 0. Note that setting global_rotation to 0 is called after rotating, Idk why but it should've been rotated way past before it. Dunno what's the cause of the problem for this can anybody inspect?'
func _shoot(customSpd: int = 0, customRot: float = 0):
if timer.is_stopped():
timer.start()
for i in repeat:
var b = bullet.instance() as BulletClass
b.global_position = global_position
if repeat != 1:
var arcRad = deg2rad(arc)
var inc = arcRad / (repeat - 1)
global_rotation += inc * i - arcRad / 2
b.dir = Vector2.RIGHT.rotated(global_rotation + customRot)
if customSpd > 0: b.spd = customSpd
get_tree().root.call_deferred("add_child", b)
global_rotation = 0
this is the code for the bullet class:
extends Area2D
class_name BulletClass
export var spd: int = 100
export var dmg: int = 1
var dir: Vector2 = Vector2.RIGHT
func _die(): pass
func hit_on_area(obj):
if obj is HurtboxClass:
obj.decrease(dmg)
_die()
func _hit_on_body(obj):
if obj is TileMap or obj is StaticBody2D:
_die()
func _movement(delta): translate(dir * spd * delta)