multiplayer pretty much works now i think
This commit is contained in:
@ -26,6 +26,15 @@ func explode():
|
||||
|
||||
func hit(target):
|
||||
target.damage(damage)
|
||||
if owner_id == 0:
|
||||
if Data.preferences.display_tower_damage_indicators:
|
||||
spawn_damage_indicator(target.sprite.global_position)
|
||||
if owner_id == multiplayer.get_unique_id():
|
||||
if Data.preferences.display_self_damage_indicators:
|
||||
spawn_damage_indicator(target.sprite.global_position)
|
||||
if owner_id != 0 and owner_id != multiplayer.get_unique_id():
|
||||
if Data.preferences.display_party_damage_indicators:
|
||||
spawn_damage_indicator(target.sprite.global_position)
|
||||
|
||||
|
||||
@rpc("reliable")
|
||||
|
@ -2,16 +2,17 @@ extends ExplosiveProjectile
|
||||
class_name HomingProjectile
|
||||
|
||||
var target : Node3D
|
||||
@export var acceleration := 40.0
|
||||
@export var max_speed := 14.0
|
||||
var acceleration := 50.0
|
||||
var max_speed := 13.0
|
||||
|
||||
|
||||
func _physics_process(_delta: float) -> void:
|
||||
if is_instance_valid(target):
|
||||
direction = global_position.direction_to(target.global_position)
|
||||
direction = global_position.direction_to(target.sprite.global_position)
|
||||
#apply_central_force(direction * acceleration)
|
||||
|
||||
|
||||
func _integrate_forces(state: PhysicsDirectBodyState3D) -> void:
|
||||
state.linear_velocity = state.linear_velocity.limit_length(state.linear_velocity.length() * (1.0 - 0.08))
|
||||
state.linear_velocity += direction * acceleration * state.step
|
||||
state.linear_velocity = state.linear_velocity.limit_length(max_speed)
|
||||
|
@ -3,6 +3,8 @@ class_name Projectile
|
||||
|
||||
@export var collision_shape : CollisionShape3D
|
||||
|
||||
var damage_particle_scene = preload("res://Scenes/damage_particle.tscn")
|
||||
var owner_id = 0 #should be left unchanged by towers, 1 for host, peer_id on peers
|
||||
var direction := Vector3.FORWARD
|
||||
var force := 2.0
|
||||
var damage := 0.0
|
||||
@ -18,6 +20,14 @@ func _process(delta: float) -> void:
|
||||
time_alive += delta
|
||||
|
||||
|
||||
func spawn_damage_indicator(pos):
|
||||
if damage > 0:
|
||||
var marker = damage_particle_scene.instantiate()
|
||||
get_tree().root.add_child(marker)
|
||||
marker.set_number(damage)
|
||||
marker.position = pos
|
||||
|
||||
|
||||
func _on_body_entered(_body: Node) -> void:
|
||||
pass # Replace with function body.
|
||||
|
||||
|
Reference in New Issue
Block a user