Players now move unsynced

This commit is contained in:
BOT Alex 2024-02-27 18:27:37 +01:00
parent c590bc893f
commit 8a3c164169
4 changed files with 7 additions and 104 deletions

View File

@ -728,67 +728,6 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1001 &820004546
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
serializedVersion: 3
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 320690117028550720, guid: 29c8b8bbcf7287b4eb597729b2e0c9f9, type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 320690117028550720, guid: 29c8b8bbcf7287b4eb597729b2e0c9f9, type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 320690117028550720, guid: 29c8b8bbcf7287b4eb597729b2e0c9f9, type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 320690117028550720, guid: 29c8b8bbcf7287b4eb597729b2e0c9f9, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 320690117028550720, guid: 29c8b8bbcf7287b4eb597729b2e0c9f9, type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 320690117028550720, guid: 29c8b8bbcf7287b4eb597729b2e0c9f9, type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 320690117028550720, guid: 29c8b8bbcf7287b4eb597729b2e0c9f9, type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 320690117028550720, guid: 29c8b8bbcf7287b4eb597729b2e0c9f9, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 320690117028550720, guid: 29c8b8bbcf7287b4eb597729b2e0c9f9, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 320690117028550720, guid: 29c8b8bbcf7287b4eb597729b2e0c9f9, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1294282455099768770, guid: 29c8b8bbcf7287b4eb597729b2e0c9f9, type: 3}
propertyPath: GlobalObjectIdHash
value: 686008210
objectReference: {fileID: 0}
- target: {fileID: 3120938410244321186, guid: 29c8b8bbcf7287b4eb597729b2e0c9f9, type: 3}
propertyPath: m_Name
value: NetworkedPlayer
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 29c8b8bbcf7287b4eb597729b2e0c9f9, type: 3}
--- !u!1 &941230147
GameObject:
m_ObjectHideFlags: 0
@ -4826,4 +4765,3 @@ SceneRoots:
- {fileID: 1481267923}
- {fileID: 65889293}
- {fileID: 652688745}
- {fileID: 820004546}

View File

@ -8,7 +8,7 @@ public class ZDisablerV2 : NetworkBehaviour
[Tooltip("Add all the objects to disable on join, if not owner")]
public UnityEngine.Object[] objectsToDisable;
private void OnEnable()
public override void OnNetworkSpawn()
{
// Run if networked
if (NetworkManager.Singleton == null || IsOwner) return;

View File

@ -32,48 +32,12 @@ public class PlayerInput : MonoBehaviour
private void Update()
{
// check in update to switch if controller is connected/disconnected mid game
controller = Gamepad.all.ElementAtOrDefault(playerNumber);
movement.x = Input.GetAxisRaw("bruh");
movement.y = Input.GetAxisRaw("bruh_v");
if (controller != null)
{
movement.x = controller.leftStick.x.ReadValue();
movement.y = controller.leftStick.y.ReadValue();
whipAttack = Input.GetKey(KeyCode.R);
look.x = controller.rightStick.x.ReadValue();
look.y = controller.rightStick.y.ReadValue();
whipAttack = controller.buttonWest.IsPressed();
if (controller.rightShoulder.IsPressed()) ropeLengthShrinken?.Invoke(playerNumber);
if (controller.leftShoulder.IsPressed()) ropeLengthExtend?.Invoke(playerNumber);
}
else
{
// wasd
if (!useArrowKeys)
{
movement.x = Input.GetAxisRaw("bruh");
movement.y = Input.GetAxisRaw("bruh_v");
whipAttack = Input.GetKey(KeyCode.R);
if (Input.GetKey(KeyCode.E)) ropeLengthShrinken?.Invoke(playerNumber);
if (Input.GetKey(KeyCode.Q)) ropeLengthExtend?.Invoke(playerNumber);
}
// arrows keys
else
{
movement.x = Input.GetAxisRaw("bruh2");
movement.y = Input.GetAxisRaw("bruh2_v");
whipAttack = Input.GetKey(KeyCode.L);
if (Input.GetKey(KeyCode.Comma)) ropeLengthShrinken?.Invoke(playerNumber);
if (Input.GetKey(KeyCode.Period)) ropeLengthExtend?.Invoke(playerNumber);
}
//Debug.Log($"player {playerNumber}: move {movement}");
}
if (Input.GetKey(KeyCode.E)) ropeLengthShrinken?.Invoke(playerNumber);
if (Input.GetKey(KeyCode.Q)) ropeLengthExtend?.Invoke(playerNumber);
}
}

View File

@ -364,6 +364,7 @@ public class RopeSimulator : MonoBehaviour
private void OnDrawGizmos()
{
return;
if (!Application.isPlaying) return;
foreach (var point in rope.points)