0 votes
extends RigidBody2D

export var min_value := 0.0
export var max_value := 100.0
export var time := 2.0

export var move_speed := 100.0
export var force_multiplier := 20.0

func _process(_delta):
    if $progress_sprite.scale == Vector2.ONE:

func _on_tween_tween_step(_object, _key, _elapsed, value):

func shoot(scale_value: Vector2) -> void:
    if Input.is_action_just_pressed('space'):
        var bullet: Area2D = load("res://objects/bullet.tscn").instance()
        bullet.scale = scale_value
        bullet.position = position
    bullet.rotation_degrees = rotation_degrees + 180

    apply_central_impulse(Vector2(100, 0))


func load_gun() -> void:
    $tween.interpolate_property($progress_sprite, 'scale', Vector2.ONE / 100 * min_value, Vector2.ONE / 100 * max_value, time, Tween.TRANS_LINEAR)

func move() -> void:
    var horizontal := Input.get_action_strength("d") - Input.get_action_strength("a")
    var vertical := Input.get_action_strength("s") - Input.get_action_strength("w")

    var vector := Vector2(horizontal, vertical)

    if vector != Vector2.ZERO:
        position += vector.normalized() * move_speed * get_process_delta_time()

player scene: https://1drv.ms/u/s!AomdJlENfLFloFNxRk3Vjd0V56px?e=FCNdbk

Godot version 3.3.2.stable.official
in Engine by (157 points)

Can you give us more information like what happens once you press "space"? Does bullet spawn? Do you have collision check implemented on bullet and player? Is it possible that bullets are colliding with player?

thanks to add_child the bullet is added to the scene, but because the player is rigidbody2d and the bullet is area2d they cannot collide.

it's because of the look_at function for some reason. How could it affect this?

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.