WIP: Spawn bullets on the server and sync them
This commit is contained in:
parent
ed53f156c0
commit
dbfcf573c2
@ -16,7 +16,7 @@ func _process(delta: float) -> void:
|
|||||||
|
|
||||||
func _on_head_collision_body_part_hit(dam: Variant) -> void:
|
func _on_head_collision_body_part_hit(dam: Variant) -> void:
|
||||||
print("head is hit" + str(dam))
|
print("head is hit" + str(dam))
|
||||||
owner_placeholder.take_damage(dam)
|
#owner_placeholder.take_damage(dam)
|
||||||
pass # Replace with function body.
|
pass # Replace with function body.
|
||||||
|
|
||||||
func _get_owner() -> CharacterBody3D:
|
func _get_owner() -> CharacterBody3D:
|
||||||
|
@ -26,11 +26,14 @@ func _ready() -> void:
|
|||||||
$MultiplayerSpawner.spawn(char)
|
$MultiplayerSpawner.spawn(char)
|
||||||
players.add_child(char)
|
players.add_child(char)
|
||||||
|
|
||||||
|
var bullet_amount: int = 0
|
||||||
func spawn_bullet(position):
|
func spawn_bullet(position):
|
||||||
print("spawning a bullet")
|
print("spawning a bullet")
|
||||||
var node: Node3D = ResourceLoader.load("res://scenes/weapon/bullet.tscn").instantiate()
|
var node: Node3D = ResourceLoader.load("res://scenes/weapon/bullet.tscn").instantiate()
|
||||||
node.position = position.global_position
|
node.position = position.global_position
|
||||||
node.transform.basis = position.global_transform.basis
|
node.transform.basis = position.global_transform.basis
|
||||||
|
node.name = str(bullet_amount)
|
||||||
|
bullet_amount += 1
|
||||||
$BulletSpawner.spawn(node)
|
$BulletSpawner.spawn(node)
|
||||||
$Bullets.add_child(node)
|
$Bullets.add_child(node)
|
||||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
|
@ -2567,6 +2567,6 @@ libraries = {
|
|||||||
[node name="BulletSpawner" type="MultiplayerSpawner" parent="."]
|
[node name="BulletSpawner" type="MultiplayerSpawner" parent="."]
|
||||||
_spawnable_scenes = PackedStringArray("res://scenes/weapon/bullet.tscn")
|
_spawnable_scenes = PackedStringArray("res://scenes/weapon/bullet.tscn")
|
||||||
spawn_path = NodePath("../Bullets")
|
spawn_path = NodePath("../Bullets")
|
||||||
spawn_limit = 8510
|
spawn_limit = 100
|
||||||
|
|
||||||
[connection signal="body_part_hit" from="Dummy/Body/Armature/Skeleton3D/BoneAttachment3D/HeadCollision" to="Dummy" method="_on_head_collision_body_part_hit"]
|
[connection signal="body_part_hit" from="Dummy/Body/Armature/Skeleton3D/BoneAttachment3D/HeadCollision" to="Dummy" method="_on_head_collision_body_part_hit"]
|
||||||
|
@ -33,13 +33,13 @@ size = Vector3(0.05, 0.05, 0.05)
|
|||||||
[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_b8q4c"]
|
[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_b8q4c"]
|
||||||
properties/0/path = NodePath(".:position")
|
properties/0/path = NodePath(".:position")
|
||||||
properties/0/spawn = true
|
properties/0/spawn = true
|
||||||
properties/0/replication_mode = 1
|
properties/0/replication_mode = 2
|
||||||
properties/1/path = NodePath(".:rotation")
|
properties/1/path = NodePath(".:rotation")
|
||||||
properties/1/spawn = true
|
properties/1/spawn = true
|
||||||
properties/1/replication_mode = 1
|
properties/1/replication_mode = 2
|
||||||
properties/2/path = NodePath(".:rotation_order")
|
properties/2/path = NodePath(".:rotation_order")
|
||||||
properties/2/spawn = true
|
properties/2/spawn = true
|
||||||
properties/2/replication_mode = 1
|
properties/2/replication_mode = 2
|
||||||
|
|
||||||
[node name="Bullet" type="Node3D"]
|
[node name="Bullet" type="Node3D"]
|
||||||
transform = Transform3D(20, 0, 0, 0, 20, 0, 0, 0, 20, 0, 0, 0)
|
transform = Transform3D(20, 0, 0, 0, 20, 0, 0, 0, 20, 0, 0, 0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user