Make it possible to dynamically set weapon parans
This commit is contained in:
@ -107,6 +107,9 @@ func _add_first_view_model() -> Error :
|
||||
var node: Node3D = scene.instantiate()
|
||||
node.scale = Vector3(0.03,0.03,0.03)
|
||||
node.position = Vector3(0.02, -0.03, -0.07)
|
||||
current_weapon_bullet_speed = node.bullet_speed
|
||||
current_weapon_cooldown_interwal = node.cooldown
|
||||
current_weapon_damage = node.damage
|
||||
gun_with_hands = node
|
||||
gun_mount.add_child(node)
|
||||
return OK
|
||||
@ -237,6 +240,9 @@ var bullet = load("res://scenes/weapon/bullet.tscn")
|
||||
@onready var shooting_raycast: RayCast3D = $FirstPersonCameraMount/RayCast3D
|
||||
@onready var bullet_starting_point: Node3D = $FirstPersonCameraMount/BulletStartingPoint
|
||||
@onready var aim_ray: RayCast3D = $FirstPersonCameraMount/BulletStartingPoint/AimRay
|
||||
var current_weapon_damage: int
|
||||
var current_weapon_bullet_speed: int
|
||||
var current_weapon_cooldown_interwal: float
|
||||
# --find the gun node and exec shoot
|
||||
var cant_shoot: bool = false
|
||||
func _shoot():
|
||||
@ -247,18 +253,18 @@ func _shoot():
|
||||
if collider != null and collider.is_in_group("target"):
|
||||
aim_ray.get_collider().take_damage()
|
||||
if collider != null and collider.is_in_group("body"):
|
||||
collider.hit()
|
||||
collider.hit(50)
|
||||
var root := get_tree().get_root()
|
||||
gun_with_hands.shoot()
|
||||
cant_shoot = true
|
||||
await get_tree().create_timer(0.2).timeout
|
||||
await get_tree().create_timer(current_weapon_cooldown_interwal).timeout
|
||||
cant_shoot = false
|
||||
|
||||
@rpc("any_peer", "call_local", "unreliable_ordered")
|
||||
func _send_shot_to_server(start_position):
|
||||
# -- TODO: Should not be hardcoded
|
||||
var world: Node3D = find_parent("ElTest")
|
||||
world.spawn_bullet(bullet_starting_point)
|
||||
world.spawn_bullet(bullet_starting_point, current_weapon_bullet_speed, current_weapon_damage)
|
||||
|
||||
func _get_camera_collision():
|
||||
var viewport = get_viewport().size
|
||||
|
Reference in New Issue
Block a user