WIP: Spawn bullets on the server and sync them

This commit is contained in:
2025-01-26 19:59:14 +01:00
parent 66efa9ec99
commit c2a5f9cf1c
5 changed files with 37 additions and 14 deletions

View File

@ -1,6 +1,6 @@
extends Node3D
const SPEED = 2
const SPEED = 200 # 200
@onready var mesh = $RigidBody3D/MeshInstance3D
@onready var rigid_body_3d: RigidBody3D = $RigidBody3D
@ -14,12 +14,15 @@ func _ready() -> void:
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
var time_per_frame: float = 1 / Engine.get_frames_per_second()
var distance: float = time_per_frame * SPEED * 1.5
ray.target_position.z = distance
position += transform.basis * Vector3(0, 0, SPEED) * delta
rigid_body_3d.set_use_continuous_collision_detection(true)
#ray.collision_mask = 1
#ray.enabled = 1
ray.target_position.z = SPEED / Engine.get_frames_per_second()
if ray.is_colliding():
print("I got hit")
rigid_body_3d.visible = false
particles.emitting = true
#if ray.get_collider().is_in_group("body"):

View File

@ -36,7 +36,7 @@ properties/0/spawn = true
properties/0/replication_mode = 2
properties/1/path = NodePath(".:rotation")
properties/1/spawn = true
properties/1/replication_mode = 0
properties/1/replication_mode = 2
[node name="Bullet" type="Node3D"]
transform = Transform3D(20, 0, 0, 0, 20, 0, 0, 0, 20, 0, 0, 0)
@ -71,7 +71,7 @@ shape = SubResource("CylinderShape3D_l3sdq")
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0.18476)
material_override = SubResource("StandardMaterial3D_ynv38")
emitting = false
amount = 10
amount = 100
lifetime = 6.29
one_shot = true
explosiveness = 1.0