Compare commits

..

No commits in common. 'dev-hazim' and 'main' have entirely different histories.

@ -75,6 +75,81 @@ MonoBehaviour:
m_FillOrigin: 0 m_FillOrigin: 0
m_UseSpriteMesh: 0 m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1 m_PixelsPerUnitMultiplier: 1
--- !u!1 &3027192775168061578
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1428306882141109911}
- component: {fileID: 794668981400312816}
- component: {fileID: 8060358920238599761}
m_Layer: 5
m_Name: Logo
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &1428306882141109911
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3027192775168061578}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 6913946062755835220}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 274.7, y: 185}
m_SizeDelta: {x: 371, y: 245}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &794668981400312816
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3027192775168061578}
m_CullTransparentMesh: 1
--- !u!114 &8060358920238599761
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3027192775168061578}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 21300000, guid: 4a7a22d18b63531438f665e67e42513b, type: 3}
m_Type: 0
m_PreserveAspect: 1
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!1 &5164871674315323616 --- !u!1 &5164871674315323616
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -167,7 +242,7 @@ GameObject:
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
m_StaticEditorFlags: 0 m_StaticEditorFlags: 0
m_IsActive: 1 m_IsActive: 0
--- !u!224 &3467790591639231224 --- !u!224 &3467790591639231224
RectTransform: RectTransform:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -182,9 +257,9 @@ RectTransform:
m_Children: [] m_Children: []
m_Father: {fileID: 6913946062755835220} m_Father: {fileID: 6913946062755835220}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMin: {x: 1, y: 0}
m_AnchorMax: {x: 0.5, y: 0.5} m_AnchorMax: {x: 1, y: 0}
m_AnchoredPosition: {x: 0, y: 0} m_AnchoredPosition: {x: -131.09998, y: 59.5}
m_SizeDelta: {x: 165, y: 38} m_SizeDelta: {x: 165, y: 38}
m_Pivot: {x: 0.5, y: 0.5} m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &7154941800200264157 --- !u!222 &7154941800200264157
@ -333,6 +408,7 @@ RectTransform:
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: m_Children:
- {fileID: 1428306882141109911}
- {fileID: 9139809042769856543} - {fileID: 9139809042769856543}
- {fileID: 3467790591639231224} - {fileID: 3467790591639231224}
m_Father: {fileID: 0} m_Father: {fileID: 0}
@ -363,14 +439,14 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
m_Material: {fileID: 0} m_Material: {fileID: 0}
m_Color: {r: 0, g: 0, b: 0, a: 1} m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1 m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1 m_Maskable: 1
m_OnCullStateChanged: m_OnCullStateChanged:
m_PersistentCalls: m_PersistentCalls:
m_Calls: [] m_Calls: []
m_Sprite: {fileID: 0} m_Sprite: {fileID: 21300000, guid: 31b6b74ea85cc724ba390ac5c29e5e07, type: 3}
m_Type: 0 m_Type: 0
m_PreserveAspect: 0 m_PreserveAspect: 0
m_FillCenter: 1 m_FillCenter: 1

@ -1,6 +1,6 @@
%YAML 1.1 %YAML 1.1
%TAG !u! tag:unity3d.com,2011: %TAG !u! tag:unity3d.com,2011:
--- !u!1 &1382721990208428792 --- !u!1 &3883971050552244427
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0} m_CorrespondingSourceObject: {fileID: 0}
@ -8,23 +8,23 @@ GameObject:
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
serializedVersion: 6 serializedVersion: 6
m_Component: m_Component:
- component: {fileID: 8690395355838649168} - component: {fileID: 7558175285853634407}
- component: {fileID: 6810852445961448004} - component: {fileID: 2850724162131160543}
- component: {fileID: 8715787529924330441} - component: {fileID: 4944058736642115274}
m_Layer: 5 m_Layer: 5
m_Name: Text (TMP) m_Name: Logo
m_TagString: Untagged m_TagString: Untagged
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
m_StaticEditorFlags: 0 m_StaticEditorFlags: 0
m_IsActive: 1 m_IsActive: 1
--- !u!224 &8690395355838649168 --- !u!224 &7558175285853634407
RectTransform: RectTransform:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0} m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0} m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1382721990208428792} m_GameObject: {fileID: 3883971050552244427}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
@ -32,29 +32,29 @@ RectTransform:
m_Children: [] m_Children: []
m_Father: {fileID: 9071773475623594905} m_Father: {fileID: 9071773475623594905}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0} m_AnchoredPosition: {x: 274.7, y: 185}
m_SizeDelta: {x: 1000.3827, y: 495.4445} m_SizeDelta: {x: 371, y: 245}
m_Pivot: {x: 0.5, y: 0.5} m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &6810852445961448004 --- !u!222 &2850724162131160543
CanvasRenderer: CanvasRenderer:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0} m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0} m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1382721990208428792} m_GameObject: {fileID: 3883971050552244427}
m_CullTransparentMesh: 1 m_CullTransparentMesh: 1
--- !u!114 &8715787529924330441 --- !u!114 &4944058736642115274
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0} m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0} m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1382721990208428792} m_GameObject: {fileID: 3883971050552244427}
m_Enabled: 1 m_Enabled: 1
m_EditorHideFlags: 0 m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3} m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
m_Material: {fileID: 0} m_Material: {fileID: 0}
@ -65,75 +65,16 @@ MonoBehaviour:
m_OnCullStateChanged: m_OnCullStateChanged:
m_PersistentCalls: m_PersistentCalls:
m_Calls: [] m_Calls: []
m_text: Loading... m_Sprite: {fileID: 21300000, guid: 4a7a22d18b63531438f665e67e42513b, type: 3}
m_isRightToLeft: 0 m_Type: 0
m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} m_PreserveAspect: 1
m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} m_FillCenter: 1
m_fontSharedMaterials: [] m_FillMethod: 4
m_fontMaterial: {fileID: 0} m_FillAmount: 1
m_fontMaterials: [] m_FillClockwise: 1
m_fontColor32: m_FillOrigin: 0
serializedVersion: 2 m_UseSpriteMesh: 0
rgba: 4294967295 m_PixelsPerUnitMultiplier: 1
m_fontColor: {r: 1, g: 1, b: 1, a: 1}
m_enableVertexGradient: 0
m_colorMode: 3
m_fontColorGradient:
topLeft: {r: 1, g: 1, b: 1, a: 1}
topRight: {r: 1, g: 1, b: 1, a: 1}
bottomLeft: {r: 1, g: 1, b: 1, a: 1}
bottomRight: {r: 1, g: 1, b: 1, a: 1}
m_fontColorGradientPreset: {fileID: 0}
m_spriteAsset: {fileID: 0}
m_tintAllSprites: 0
m_StyleSheet: {fileID: 0}
m_TextStyleHashCode: -1183493901
m_overrideHtmlColors: 0
m_faceColor:
serializedVersion: 2
rgba: 4294967295
m_fontSize: 168.1
m_fontSizeBase: 168.1
m_fontWeight: 400
m_enableAutoSizing: 0
m_fontSizeMin: 18
m_fontSizeMax: 126.03
m_fontStyle: 0
m_HorizontalAlignment: 2
m_VerticalAlignment: 512
m_textAlignment: 65535
m_characterSpacing: 0
m_wordSpacing: 0
m_lineSpacing: 0
m_lineSpacingMax: 0
m_paragraphSpacing: 0
m_charWidthMaxAdj: 0
m_enableWordWrapping: 1
m_wordWrappingRatios: 0.4
m_overflowMode: 0
m_linkedTextComponent: {fileID: 0}
parentLinkedComponent: {fileID: 0}
m_enableKerning: 1
m_enableExtraPadding: 0
checkPaddingRequired: 0
m_isRichText: 1
m_parseCtrlCharacters: 1
m_isOrthographic: 1
m_isCullingEnabled: 0
m_horizontalMapping: 0
m_verticalMapping: 0
m_uvLineOffset: 0
m_geometrySortingOrder: 0
m_IsTextObjectScaleStatic: 0
m_VertexBufferAutoSizeReduction: 0
m_useMaxVisibleDescender: 1
m_pageToDisplay: 1
m_margin: {x: 0, y: 0, z: 0, w: 0}
m_isUsingLegacyAnimationComponent: 0
m_isVolumetricText: 0
m_hasFontAssetChanged: 0
m_baseMaterial: {fileID: 0}
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
--- !u!1 &5679638553482947985 --- !u!1 &5679638553482947985
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -165,7 +106,7 @@ RectTransform:
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: m_Children:
- {fileID: 8690395355838649168} - {fileID: 7558175285853634407}
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0} m_AnchorMin: {x: 0, y: 0}
@ -194,14 +135,14 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
m_Material: {fileID: 0} m_Material: {fileID: 0}
m_Color: {r: 0, g: 0, b: 0, a: 1} m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1 m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1 m_Maskable: 1
m_OnCullStateChanged: m_OnCullStateChanged:
m_PersistentCalls: m_PersistentCalls:
m_Calls: [] m_Calls: []
m_Sprite: {fileID: 0} m_Sprite: {fileID: 21300000, guid: 31b6b74ea85cc724ba390ac5c29e5e07, type: 3}
m_Type: 0 m_Type: 0
m_PreserveAspect: 0 m_PreserveAspect: 0
m_FillCenter: 1 m_FillCenter: 1

@ -1,3 +1,4 @@
using Fusion; using Fusion;
using UnityEngine; using UnityEngine;
using DG.Tweening; using DG.Tweening;
@ -6,104 +7,103 @@ using Fusion.Addons.SimpleKCC;
[DefaultExecutionOrder(-5)] [DefaultExecutionOrder(-5)]
public sealed class TopDownPlayer : NetworkBehaviour public sealed class TopDownPlayer : NetworkBehaviour
{ {
//=================================================== //===================================================
// FIELDS // FIELDS
//=================================================== //===================================================
[SerializeField] KCC _kcc = null; [SerializeField] KCC _kcc = null;
[SerializeField] TopDownPlayerInput _input = null; [SerializeField] TopDownPlayerInput _input = null;
[SerializeField] AnimationController _animator = null; [SerializeField] AnimationController _animator = null;
//=================================================== //===================================================
// PRIVATE FIELDS // PRIVATE FIELDS
//=================================================== //===================================================
private MovementData _moveData = new(); private MovementData _moveData = new();
[Networked] [Networked]
private int _jumpCount { get; set; } private int _jumpCount { get; set; }
private int _lastVisibleJump; private int _lastVisibleJump;
[Networked] [Networked]
private int _attackCount { get; set; } private int _attackCount { get; set; }
private int _lastVisibleAttack; private int _lastVisibleAttack;
//=================================================== //===================================================
// PROPERTIES // PROPERTIES
//=================================================== //===================================================
public float Speed => _moveData.Speed; public float Speed => _moveData.Speed;
public KCC KCC => _kcc; public KCC KCC => _kcc;
public TopDownPlayerInput Input => _input; public TopDownPlayerInput Input => _input;
private MovementSettings MoveSettings => GameData.Instance.MovementSettings; private MovementSettings MoveSettings => GameData.Instance.MovementSettings;
//=================================================== //===================================================
// METHODS // METHODS
//=================================================== //===================================================
public override void Spawned() public override void Spawned()
{ {
base.Spawned(); base.Spawned();
_lastVisibleJump = _jumpCount; _lastVisibleJump = _jumpCount;
_lastVisibleAttack = _attackCount; _lastVisibleAttack = _attackCount;
if(_kcc == null) if(_kcc == null)
_kcc = GetComponent<KCC>(); _kcc = GetComponent<KCC>();
if(_input == null) if(_input == null)
_input = GetComponent<TopDownPlayerInput>(); _input = GetComponent<TopDownPlayerInput>();
if (_moveData.MainCamera == null) if (_moveData.MainCamera == null)
_moveData.MainCamera = GameObject.FindGameObjectWithTag("MainCamera"); _moveData.MainCamera = GameObject.FindGameObjectWithTag("MainCamera");
if(_animator == null) if(_animator == null)
_animator = GetComponent<AnimationController>(); _animator = GetComponent<AnimationController>();
}//Spawned() end }//Spawned() end
public override void FixedUpdateNetwork() public override void FixedUpdateNetwork()
{ {
if(Input == null) if(Input == null)
return; return;
_moveData.TargetSpeed = Input.CurrentInput.Sprint == true ? MoveSettings.SprintSpeed : MoveSettings.MoveSpeed; _moveData.TargetSpeed = Input.CurrentInput.Sprint == true ? MoveSettings.SprintSpeed : MoveSettings.MoveSpeed;
if(Input.CurrentInput.MoveDirection != Vector2.zero) if(Input.CurrentInput.MoveDirection != Vector2.zero)
{ {
Vector3 moveDirection = new Vector3(Input.CurrentInput.MoveDirection.x, 0.0f, Input.CurrentInput.MoveDirection.y); _moveData.TargetRotation = KCC.GetLookRotation(false, true).y;
_moveData.TargetRotation = Quaternion.LookRotation(moveDirection).eulerAngles.y; _moveData.TargetRotation = Mathf.Atan2(Input.CurrentInput.MoveDirection.x, Input.CurrentInput.MoveDirection.y) * Mathf.Rad2Deg + _moveData.MainCamera.transform.eulerAngles.y;
_moveData.TargetRotation = Mathf.SmoothDampAngle(transform.eulerAngles.y, _moveData.TargetRotation, ref _moveData.RotationVelocity, MoveSettings.RotationSmooth); _moveData.TargetRotationMove = _moveData.TargetRotation + _moveData.MainCamera.transform.eulerAngles.y;
_moveData.TargetRotation = Mathf.SmoothDampAngle(transform.eulerAngles.y, _moveData.TargetRotation, ref _moveData.RotationVelocity, MoveSettings.RotationSmooth);
KCC.SetLookRotation(new Vector2(0f, _moveData.TargetRotation)); KCC.SetLookRotation(new Vector2(0f, _moveData.TargetRotation));
}//if end }//if end
else else
{
_moveData.TargetRotationMove = 0f; _moveData.TargetRotationMove = 0f;
}
if(Input.CurrentInput.MoveDirection != Vector2.zero) if(Input.CurrentInput.MoveDirection != Vector2.zero)
{ {
_moveData.InputDirection = Quaternion.Euler(0.0f, _moveData.TargetRotation, 0.0f) * Vector3.forward; _moveData.InputDirection = Quaternion.Euler(0.0f, _moveData.TargetRotationMove, 0.0f) * Vector3.forward;
} _moveData.InputDirection.x += Input.CurrentInput.MoveDirection.x;
_moveData.InputDirection.z += Input.CurrentInput.MoveDirection.y;
}//if end
else else
{
_moveData.InputDirection = Vector3.zero; _moveData.InputDirection = Vector3.zero;
}
if (KCC.IsGrounded && Input.CurrentInput.AttackAction.WasPressed(Input.PreviousInput.AttackAction, NetworkedInput.ATTACK_BUTTON) == true) if (KCC.IsGrounded && Input.CurrentInput.AttackAction.WasPressed(Input.PreviousInput.AttackAction, NetworkedInput.ATTACK_BUTTON) == true)
_attackCount++; _attackCount++;
if (KCC.IsGrounded && Input.CurrentInput.JumpAction.WasPressed(Input.PreviousInput.JumpAction, NetworkedInput.JUMP_BUTTON) == true) if (KCC.IsGrounded && Input.CurrentInput.JumpAction.WasPressed(Input.PreviousInput.JumpAction, NetworkedInput.JUMP_BUTTON) == true)
{ {
DOTween.To(()=> _moveData.JumpImpulse, x=> _moveData.JumpImpulse = x, MoveSettings.JumpImpulsePeak, 0.25f).SetEase(Ease.InExpo).OnComplete(()=> DOTween.To(()=> _moveData.JumpImpulse, x=> _moveData.JumpImpulse = x, MoveSettings.JumpImpulsePeak, 0.25f).SetEase(Ease.InExpo).OnComplete(()=>
DOTween.To(()=> _moveData.JumpImpulse, x=> _moveData.JumpImpulse = x, 0f, 0.25f).SetEase(Ease.InExpo)); DOTween.To(()=> _moveData.JumpImpulse, x=> _moveData.JumpImpulse = x, 0f, 0.25f).SetEase(Ease.InExpo));
_jumpCount++; _jumpCount++;
}//if end }//if end
// It feels better when the player falls quicker. // It feels better when the player falls quicker.
KCC.SetGravity(KCC.RealVelocity.y >= 0.0f ? MoveSettings.UpGravity : MoveSettings.DownGravity); KCC.SetGravity(KCC.RealVelocity.y >= 0.0f ? MoveSettings.UpGravity : MoveSettings.DownGravity);
_moveData.MovementSpeed = Input.CurrentInput.MoveDirection.magnitude; _moveData.MovementSpeed = Input.CurrentInput.MoveDirection.magnitude;
if(_moveData.MovementSpeed > 0.01f) if(_moveData.MovementSpeed > 0.01f)
_moveData.Speed = Mathf.Lerp(_moveData.Speed, _moveData.MovementSpeed > 0.01f ? _moveData.TargetSpeed : 0f, Runner.DeltaTime * 10f); _moveData.Speed = Mathf.Lerp(_moveData.Speed, _moveData.MovementSpeed > 0.01f ? _moveData.TargetSpeed : 0f, Runner.DeltaTime * 10f);
else else
_moveData.Speed = 0f; _moveData.Speed = 0f;
_moveData.DesiredMoveVelocity = _moveData.InputDirection * _moveData.Speed; _moveData.DesiredMoveVelocity = _moveData.InputDirection * _moveData.Speed;
if (KCC.ProjectOnGround(_moveData.DesiredMoveVelocity, out Vector3 projectedDesiredMoveVelocity) == true) if (KCC.ProjectOnGround(_moveData.DesiredMoveVelocity, out Vector3 projectedDesiredMoveVelocity) == true)
_moveData.DesiredMoveVelocity = Vector3.Normalize(projectedDesiredMoveVelocity) * _moveData.Speed; _moveData.DesiredMoveVelocity = Vector3.Normalize(projectedDesiredMoveVelocity) * _moveData.Speed;
@ -113,23 +113,23 @@ public sealed class TopDownPlayer : NetworkBehaviour
else else
_moveData.Acceleration = KCC.IsGrounded == true ? MoveSettings.GroundAcceleration : MoveSettings.AirAcceleration; _moveData.Acceleration = KCC.IsGrounded == true ? MoveSettings.GroundAcceleration : MoveSettings.AirAcceleration;
_moveData.MoveVelocity = Vector3.Lerp(_moveData.MoveVelocity, _moveData.DesiredMoveVelocity, _moveData.Acceleration * Runner.DeltaTime); _moveData.MoveVelocity = Vector3.Lerp(_moveData.MoveVelocity, _moveData.DesiredMoveVelocity, _moveData.Acceleration * Runner.DeltaTime);
KCC.Move(_moveData.MoveVelocity, _moveData.JumpImpulse); KCC.Move(_moveData.MoveVelocity, _moveData.JumpImpulse);
}//FixedUpdateNetwork() end }//FixedUpdateNetwork() end
public override void Render() public override void Render()
{ {
_animator.Animate(KCC.IsGrounded, Speed, Runner.DeltaTime); _animator.Animate(KCC.IsGrounded, Speed, Runner.DeltaTime);
if (_lastVisibleJump < _jumpCount) if (_lastVisibleJump < _jumpCount)
_animator.Jump(); _animator.Jump();
_lastVisibleJump = _jumpCount; _lastVisibleJump = _jumpCount;
if (_lastVisibleAttack < _attackCount) if (_lastVisibleAttack < _attackCount)
_animator.Attack(); _animator.Attack();
_lastVisibleAttack = _attackCount; _lastVisibleAttack = _attackCount;
}//Render() end }//Render() end
}//class end }//class end

@ -1,3 +1,4 @@
using Fusion; using Fusion;
using StarterAssets; using StarterAssets;
using UnityEngine; using UnityEngine;
@ -9,134 +10,127 @@ using UnityEngine.InputSystem;
[DefaultExecutionOrder(-10)] [DefaultExecutionOrder(-10)]
public sealed class TopDownPlayerInput : NetworkBehaviour, IBeforeUpdate, IBeforeTick, INetworkInput public sealed class TopDownPlayerInput : NetworkBehaviour, IBeforeUpdate, IBeforeTick, INetworkInput
{ {
public NetworkedInput CurrentInput => _currentInput; public NetworkedInput CurrentInput => _currentInput;
public NetworkedInput PreviousInput => _previousInput; public NetworkedInput PreviousInput => _previousInput;
//=================================================== //===================================================
// PRIVATE FIELDS // PRIVATE FIELDS
//=================================================== //===================================================
private UICanvasControllerInput _mobileInput = null; private UICanvasControllerInput _mobileInput = null;
[Networked] [Networked]
private NetworkedInput _currentInput { get; set; } private NetworkedInput _currentInput { get; set; }
private bool _resetAccumulatedInput; private bool _resetAccumulatedInput;
private NetworkedInput _accumulatedInput; private NetworkedInput _accumulatedInput;
private NetworkedInput _previousInput; private NetworkedInput _previousInput;
private Vector3 _targetPosition; //===================================================
private bool _isClickToMoveActive; // METHODS
//===================================================
//=================================================== public override void Spawned()
// METHODS {
//=================================================== // Reset to default state.
public override void Spawned() _currentInput = default;
{ _previousInput = default;
// Reset to default state. _accumulatedInput = default;
_currentInput = default; _resetAccumulatedInput = default;
_previousInput = default;
_accumulatedInput = default; if (Object.HasInputAuthority == true)
_resetAccumulatedInput = default; {
_isClickToMoveActive = false; Runner.GetComponent<ClientSessionHandler>().OnInputAction += OnInput;
if (Object.HasInputAuthority == true) if(Application.isMobilePlatform)
{ {
Runner.GetComponent<ClientSessionHandler>().OnInputAction += OnInput; _mobileInput = Runner.GetComponent<ClientSessionHandler>().MobileInput;
}//if end
if (Application.isMobilePlatform) // else if(Application.isEditor)
{ // {
_mobileInput = Runner.GetComponent<ClientSessionHandler>().MobileInput; // Cursor.lockState = CursorLockMode.Locked;
}//if end // Cursor.visible = false;
}//if end // }//if end
}//if end
ReplicateToAll(false);
ReplicateTo(Object.InputAuthority, true); ReplicateToAll(false);
}//Spawned() end ReplicateTo(Object.InputAuthority, true);
}//Spawned() end
void IBeforeUpdate.BeforeUpdate()
{ void IBeforeUpdate.BeforeUpdate()
if (HasInputAuthority == false) {
return; if (HasInputAuthority == false)
return;
if (_resetAccumulatedInput == true)
{ if (_resetAccumulatedInput == true)
_resetAccumulatedInput = false; {
_accumulatedInput = default; _resetAccumulatedInput = false;
}//if end _accumulatedInput = default;
}//if end
if (Application.isMobilePlatform)
{ if(Application.isMobilePlatform)
MobileInput(); {
}//if end MobileInput();
else }//if end
{ else
ClickToMoveInput(); {
}//else end // if (Cursor.lockState != CursorLockMode.Locked)
}//BeforeUpdate() end // return;
void IBeforeTick.BeforeTick() StandaloneInput();
{ }//if end
if (Object == null)
return; }//BeforeUpdate() end
_previousInput = _currentInput; void IBeforeTick.BeforeTick()
NetworkedInput currentInput = _currentInput; {
_currentInput = currentInput; if (Object == null)
return;
if (Object.InputAuthority != PlayerRef.None)
{ _previousInput = _currentInput;
if (GetInput(out NetworkedInput input) == true) NetworkedInput currentInput = _currentInput;
_currentInput = input; _currentInput = currentInput;
}//if end
}//BeforeTick() end if (Object.InputAuthority != PlayerRef.None)
{
private void OnInput(NetworkRunner runner, NetworkInput networkInput) if (GetInput(out NetworkedInput input) == true)
{ _currentInput = input;
networkInput.Set(_accumulatedInput); }//if end
_resetAccumulatedInput = true; }//BeforeTick() end
}//OnInput() end
private void OnInput(NetworkRunner runner, NetworkInput networkInput)
private void ClickToMoveInput() {
{ networkInput.Set(_accumulatedInput);
if (Mouse.current != null && Mouse.current.leftButton.wasPressedThisFrame) _resetAccumulatedInput = true;
{ }//OnInput() end
Ray ray = Camera.main.ScreenPointToRay(Mouse.current.position.ReadValue());
if (Physics.Raycast(ray, out RaycastHit hit)) private void StandaloneInput()
{ {
_targetPosition = hit.point; Keyboard keyboard = Keyboard.current;
_isClickToMoveActive = true; if (keyboard != null)
}//if end {
}//if end Vector2 moveDirection = Vector2.zero;
if (_isClickToMoveActive) if (keyboard.wKey.isPressed == true) { moveDirection += Vector2.up ; }
{ if (keyboard.sKey.isPressed == true) { moveDirection += Vector2.down ; }
Vector3 direction = (_targetPosition - transform.position).normalized; if (keyboard.aKey.isPressed == true) { moveDirection += Vector2.left ; }
direction.y = 0; // Ignore vertical movement if (keyboard.dKey.isPressed == true) { moveDirection += Vector2.right; }
if (Vector3.Distance(transform.position, _targetPosition) > 0.1f) _accumulatedInput.MoveDirection = moveDirection.normalized;
{ _accumulatedInput.Sprint = keyboard.leftShiftKey.isPressed;
_accumulatedInput.MoveDirection = new Vector2(direction.x, direction.z).normalized; _accumulatedInput.JumpAction.Set(NetworkedInput.JUMP_BUTTON, keyboard.spaceKey.isPressed);
} }//if end
else
{ if(Mouse.current != null)
_accumulatedInput.MoveDirection = Vector2.zero; _accumulatedInput.AttackAction.Set(NetworkedInput.ATTACK_BUTTON, Mouse.current.leftButton.isPressed);
_isClickToMoveActive = false; }//StandaloneInput() end
}//else end
}//if end private void MobileInput()
else {
{ if(_mobileInput is null)
_accumulatedInput.MoveDirection = Vector2.zero; return;
}//else end
}//ClickToMoveInput() end _accumulatedInput.MoveDirection = _mobileInput.Move;
_accumulatedInput.Sprint = _mobileInput.Sprint;
private void MobileInput() _accumulatedInput.JumpAction.Set(NetworkedInput.JUMP_BUTTON, _mobileInput.Jump);
{ _accumulatedInput.AttackAction.Set(NetworkedInput.ATTACK_BUTTON, _mobileInput.Attack);
if (_mobileInput is null) }//MobileInput() end
return;
_accumulatedInput.MoveDirection = _mobileInput.Move;
_accumulatedInput.Sprint = _mobileInput.Sprint;
_accumulatedInput.JumpAction.Set(NetworkedInput.JUMP_BUTTON, _mobileInput.Jump);
_accumulatedInput.AttackAction.Set(NetworkedInput.ATTACK_BUTTON, _mobileInput.Attack);
}//MobileInput() end
}//class end }//class end

@ -19,7 +19,7 @@ namespace DedicatedServer
Application.targetFrameRate = 60; Application.targetFrameRate = 60;
var config = DedicatedServerConfig.Resolve(); var config = DedicatedServerConfig.Resolve();
Debug.Log(config); Log.Debug(config);
// Start a new Runner instance // Start a new Runner instance
var runner = Instantiate(_runnerPrefab); var runner = Instantiate(_runnerPrefab);
@ -30,13 +30,13 @@ namespace DedicatedServer
// Check if all went fine // Check if all went fine
if (result.Ok) if (result.Ok)
{ {
Debug.Log($"Runner Start DONE"); Log.Debug($"Runner Start DONE");
// Log.Debug(PhotonAppSettings.Global.AppSettings.BestRegionSummaryFromStorage); // Log.Debug(PhotonAppSettings.Global.AppSettings.BestRegionSummaryFromStorage);
} }
else else
{ {
// Quit the application if startup fails // Quit the application if startup fails
Debug.Log($"Error while starting Server: {result.ShutdownReason}"); Log.Debug($"Error while starting Server: {result.ShutdownReason}");
// it can be used any error code that can be read by an external application // it can be used any error code that can be read by an external application
// using 0 means all went fine // using 0 means all went fine

@ -11,7 +11,6 @@
"com.unity.test-framework": "1.1.33", "com.unity.test-framework": "1.1.33",
"com.unity.textmeshpro": "3.0.8", "com.unity.textmeshpro": "3.0.8",
"com.unity.timeline": "1.7.6", "com.unity.timeline": "1.7.6",
"com.unity.toolchain.win-x86_64-linux-x86_64": "2.0.10",
"com.unity.ugui": "1.0.0", "com.unity.ugui": "1.0.0",
"com.unity.modules.ai": "1.0.0", "com.unity.modules.ai": "1.0.0",
"com.unity.modules.androidjni": "1.0.0", "com.unity.modules.androidjni": "1.0.0",

@ -128,22 +128,6 @@
"com.unity.searcher": "4.9.2" "com.unity.searcher": "4.9.2"
} }
}, },
"com.unity.sysroot": {
"version": "2.0.10",
"depth": 1,
"source": "registry",
"dependencies": {},
"url": "https://packages.unity.com"
},
"com.unity.sysroot.linux-x86_64": {
"version": "2.0.9",
"depth": 1,
"source": "registry",
"dependencies": {
"com.unity.sysroot": "2.0.10"
},
"url": "https://packages.unity.com"
},
"com.unity.test-framework": { "com.unity.test-framework": {
"version": "1.1.33", "version": "1.1.33",
"depth": 0, "depth": 0,
@ -176,16 +160,6 @@
}, },
"url": "https://packages.unity.com" "url": "https://packages.unity.com"
}, },
"com.unity.toolchain.win-x86_64-linux-x86_64": {
"version": "2.0.10",
"depth": 0,
"source": "registry",
"dependencies": {
"com.unity.sysroot": "2.0.10",
"com.unity.sysroot.linux-x86_64": "2.0.9"
},
"url": "https://packages.unity.com"
},
"com.unity.ugui": { "com.unity.ugui": {
"version": "1.0.0", "version": "1.0.0",
"depth": 0, "depth": 0,

@ -140,8 +140,7 @@ PlayerSettings:
visionOSBundleVersion: 1.0 visionOSBundleVersion: 1.0
tvOSBundleVersion: 1.0 tvOSBundleVersion: 1.0
bundleVersion: 1 bundleVersion: 1
preloadedAssets: preloadedAssets: []
- {fileID: 11400000, guid: 8067e0a3499c4b44ab5a819cfe0c9f88, type: 2}
metroInputSource: 0 metroInputSource: 0
wsaTransparentSwapchain: 0 wsaTransparentSwapchain: 0
m_HolographicPauseOnTrackingLoss: 1 m_HolographicPauseOnTrackingLoss: 1

Loading…
Cancel
Save