Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | thoma |
Hi I try to make a shotgun bullet and I want to decide to change the size of the dispersion and a damge reduce by distance the bullet do and fix it minimum and max damage to 1 for the reduce damage by distance.
script for bullet 1:
extends Area2D
const speed = 900
export(int) var damage = 10
var velocity = Vector2(1,1)
func shoot_at_mouse(start_pos):
self.global_position = start_pos
var direction = (get_global_mouse_position() - start_pos).normalized()
self.linear_velocity = -direction * speed
func _physics_process(delta):
velocity.x = speed * delta
velocity.y = speed * -delta
translate(velocity)
set_position(get_position()+velocity*-delta)
script bullet 2:
extends Area2D
const speed = 900
export(int) var damage = 10
var velocity = Vector2()
func shoot_at_mouse(start_pos):
self.global_position = start_pos
var direction = (get_global_mouse_position() - start_pos).normalized()
self.linear_velocity = direction * speed
func _physics_process(delta):
velocity.x = speed * delta
translate(velocity)
set_position(get_position()+velocity*delta)
script bullet 3:
extends Area2D
const speed = 900
export(int) var damage = 10
var velocity = Vector2(-1,1)
func shoot_at_mouse(start_pos):
self.global_position = start_pos
var direction = (get_global_mouse_position() - start_pos).normalized()
self.linear_velocity = -direction * speed
func _physics_process(delta):
velocity.x = speed * delta
velocity.y = speed * delta
translate(velocity)
set_position(get_position()+velocity*-delta)
Thank for helping me
Hello! Why you have 3 different bullet nodes?
fershopls | 2019-07-30 04:34
yeah a use three bullet to give the “effect” of dispersion of a shotgun bullet.It just a part of the design of the weapon.
Edit:actually I find the solution for the dispersion but anyway could you just explain me how to to the damage reduce by distance whit a max damage and a minimum damage.
thoma | 2019-07-30 17:07