Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | ROBOTOO007 |
basically im trying to make a basic gun in my game but the bullets wont spawn at the right place and they arent rotated correctly and they dont go in the right direction
here’s my bullet code:
export (int) var speed
var velocity = Vector2()
var difBulletMouse: Vector2
func start(_positon, _direction, _rotation):
$bullet.scale = Vector2(10,10)
position = _positon
velocity = _direction * speed
rotation_degrees = _rotation
func _process(delta: float) -> void:
position += velocity * delta
and here’s my player code:
there's more code here but it's irrelevant
if Input.is_action_just_pressed("shoot"):
shoot($player_arm/bullet_SpawnPoint.position, arm_direction.normalized(), $player_arm.rotation_degrees)
func shoot(_position, _direction, _rotation):
var bullet_inst = bullet.instance()
bullet_inst.start(_position, _direction, _rotation)
get_parent().add_child(bullet_inst)