MP sync working, redoing all menus now
This commit is contained in:
@@ -1,27 +1,34 @@
|
||||
extends RigidBody2D
|
||||
|
||||
@onready var rigid_body = get_node(".")
|
||||
@export var initial_impulse:Vector2 = Vector2(0,0)
|
||||
@export var damage_speed:int = 50
|
||||
@export var max_speed:int = 150
|
||||
@export var push_strength:int = 20
|
||||
|
||||
@onready var last_velocity:Vector2 = Vector2(0,0)
|
||||
@onready var current_player:CharacterBody2D = null
|
||||
|
||||
@export var initial_impulse:Vector2 = Vector2(0,0)
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
print("Statue Ready!")
|
||||
if initial_impulse != Vector2.ZERO:
|
||||
rigid_body.apply_central_impulse(initial_impulse)
|
||||
|
||||
|
||||
func _physics_process(delta):
|
||||
last_velocity = get_linear_velocity()
|
||||
if last_velocity.length() > damage_speed:
|
||||
set_modulate(Color("8e2325"))
|
||||
else:
|
||||
set_modulate(Color("ffffff"))
|
||||
if last_velocity.length() > max_speed:
|
||||
set_linear_velocity(get_linear_velocity().normalized() * max_speed)
|
||||
last_velocity.length()
|
||||
|
||||
|
||||
func _on_body_entered(body):
|
||||
print("body entered! ")
|
||||
if body.is_in_group("player"):
|
||||
print("Player collided!")
|
||||
current_player = body
|
||||
current_player.player_hit.is_player_hit = true
|
||||
current_player.player_hit.hit_velocity = last_velocity
|
||||
|
||||
if last_velocity.x > 50 or last_velocity.y < -50 or last_velocity.x < -50 or last_velocity.y > 50:
|
||||
if last_velocity.length() > damage_speed:
|
||||
current_player = body
|
||||
current_player.player_hit.is_player_hit = true
|
||||
current_player.player_hit.hit_velocity = last_velocity.normalized() * push_strength
|
||||
current_player.health_changed_func(-1)
|
||||
rigid_body.set_sleeping(true)
|
||||
# set_freeze_enabled(true)
|
||||
# await get_tree().create_timer(0.5).timeout
|
||||
set_sleeping(true)
|
||||
# set_freeze_enabled(false)
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
[gd_scene load_steps=5 format=3 uid="uid://ca4ghctk5gllj"]
|
||||
[gd_scene load_steps=6 format=3 uid="uid://ca4ghctk5gllj"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://cgtkkroa583fo" path="res://TileSets/Stuff.png" id="1_462gd"]
|
||||
[ext_resource type="Script" path="res://PhysicsObjects/HandStatue/HandStatue.gd" id="1_ap0lt"]
|
||||
@@ -12,12 +12,21 @@ bounce = 0.76
|
||||
radius = 9.0
|
||||
height = 34.0
|
||||
|
||||
[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_14ixl"]
|
||||
properties/0/path = NodePath(".:position")
|
||||
properties/0/spawn = false
|
||||
properties/0/sync = false
|
||||
properties/1/path = NodePath(".:linear_velocity")
|
||||
properties/1/spawn = false
|
||||
properties/1/sync = true
|
||||
|
||||
[node name="HandStatue" type="RigidBody2D" groups=["moveable"]]
|
||||
physics_material_override = SubResource("PhysicsMaterial_ho34d")
|
||||
max_contacts_reported = 3
|
||||
contact_monitor = true
|
||||
can_sleep = false
|
||||
lock_rotation = true
|
||||
script = ExtResource("1_ap0lt")
|
||||
initial_impulse = Vector2(200, 0)
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
position = Vector2(0, -4)
|
||||
@@ -29,4 +38,7 @@ texture = ExtResource("1_462gd")
|
||||
region_enabled = true
|
||||
region_rect = Rect2(48, 36, 16, 28)
|
||||
|
||||
[node name="MultiplayerSynchronizer" type="MultiplayerSynchronizer" parent="."]
|
||||
replication_config = SubResource("SceneReplicationConfig_14ixl")
|
||||
|
||||
[connection signal="body_entered" from="." to="." method="_on_body_entered"]
|
||||
|
18
PhysicsObjects/HandStatue/MultiplayerSynchronizer.gd
Normal file
18
PhysicsObjects/HandStatue/MultiplayerSynchronizer.gd
Normal file
@@ -0,0 +1,18 @@
|
||||
extends MultiplayerSynchronizer
|
||||
|
||||
|
||||
#func _enter_tree():
|
||||
# set_multiplayer_authority(1)
|
||||
#
|
||||
## Called when the node enters the scene tree for the first time.
|
||||
#func _ready():
|
||||
# if not is_multiplayer_authority(): return
|
||||
#
|
||||
#
|
||||
## Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
#func _process(delta):
|
||||
# if not is_multiplayer_authority(): return
|
||||
#
|
||||
#
|
||||
#func _physics_process(delta):
|
||||
# if not is_multiplayer_authority(): return
|
Reference in New Issue
Block a user