Add per-weapon scene and better first person view
This commit is contained in:
26
scenes/weapon/guns/ak/with_hands.gd
Normal file
26
scenes/weapon/guns/ak/with_hands.gd
Normal file
@ -0,0 +1,26 @@
|
||||
extends Node3D
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
pass # Replace with function body.
|
||||
@onready var barrel: Node3D = $Barrel
|
||||
|
||||
func shoot() -> Error:
|
||||
# -- TODO: It should not be hardcoded
|
||||
var path := "res://scenes/weapon/guns/ak/bullet.tscn"
|
||||
if not ResourceLoader.exists(path):
|
||||
return ERR_DOES_NOT_EXIST
|
||||
var scene: PackedScene = ResourceLoader.load(path)
|
||||
if not scene.can_instantiate():
|
||||
return ERR_CANT_OPEN
|
||||
var node: Node3D = scene.instantiate()
|
||||
var root := get_tree().get_root()
|
||||
node.position = barrel.global_position
|
||||
node.transform.basis = barrel.global_transform.basis
|
||||
root.add_child(node)
|
||||
return OK
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
pass
|
Reference in New Issue
Block a user