mirror of
				https://github.com/DerTyp7/defrain-shooter-unity.git
				synced 2025-10-29 20:52:10 +01:00 
			
		
		
		
	Merge branch 'player-info'
This commit is contained in:
		| @@ -1,5 +1,36 @@ | |||||||
| %YAML 1.1 | %YAML 1.1 | ||||||
| %TAG !u! tag:unity3d.com,2011: | %TAG !u! tag:unity3d.com,2011: | ||||||
|  | --- !u!1 &659942595732761248 | ||||||
|  | GameObject: | ||||||
|  |   m_ObjectHideFlags: 0 | ||||||
|  |   m_CorrespondingSourceObject: {fileID: 0} | ||||||
|  |   m_PrefabInstance: {fileID: 0} | ||||||
|  |   m_PrefabAsset: {fileID: 0} | ||||||
|  |   serializedVersion: 6 | ||||||
|  |   m_Component: | ||||||
|  |   - component: {fileID: 7283872597117707309} | ||||||
|  |   m_Layer: 0 | ||||||
|  |   m_Name: CameraPos | ||||||
|  |   m_TagString: Untagged | ||||||
|  |   m_Icon: {fileID: 0} | ||||||
|  |   m_NavMeshLayer: 0 | ||||||
|  |   m_StaticEditorFlags: 0 | ||||||
|  |   m_IsActive: 1 | ||||||
|  | --- !u!4 &7283872597117707309 | ||||||
|  | Transform: | ||||||
|  |   m_ObjectHideFlags: 0 | ||||||
|  |   m_CorrespondingSourceObject: {fileID: 0} | ||||||
|  |   m_PrefabInstance: {fileID: 0} | ||||||
|  |   m_PrefabAsset: {fileID: 0} | ||||||
|  |   m_GameObject: {fileID: 659942595732761248} | ||||||
|  |   m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} | ||||||
|  |   m_LocalPosition: {x: 0.28639913, y: -0.44462323, z: 0.48100734} | ||||||
|  |   m_LocalScale: {x: 1, y: 1, z: 1} | ||||||
|  |   m_Children: | ||||||
|  |   - {fileID: 6272346181657429396} | ||||||
|  |   m_Father: {fileID: 981273033772084037} | ||||||
|  |   m_RootOrder: 0 | ||||||
|  |   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} | ||||||
| --- !u!1 &681358948229890261 | --- !u!1 &681358948229890261 | ||||||
| GameObject: | GameObject: | ||||||
|   m_ObjectHideFlags: 0 |   m_ObjectHideFlags: 0 | ||||||
| @@ -82,6 +113,36 @@ MeshRenderer: | |||||||
|   m_SortingLayer: 0 |   m_SortingLayer: 0 | ||||||
|   m_SortingOrder: 0 |   m_SortingOrder: 0 | ||||||
|   m_AdditionalVertexStreams: {fileID: 0} |   m_AdditionalVertexStreams: {fileID: 0} | ||||||
|  | --- !u!1 &3649358604728444914 | ||||||
|  | GameObject: | ||||||
|  |   m_ObjectHideFlags: 0 | ||||||
|  |   m_CorrespondingSourceObject: {fileID: 0} | ||||||
|  |   m_PrefabInstance: {fileID: 0} | ||||||
|  |   m_PrefabAsset: {fileID: 0} | ||||||
|  |   serializedVersion: 6 | ||||||
|  |   m_Component: | ||||||
|  |   - component: {fileID: 5021921342190399731} | ||||||
|  |   m_Layer: 0 | ||||||
|  |   m_Name: Muzzle | ||||||
|  |   m_TagString: Untagged | ||||||
|  |   m_Icon: {fileID: 0} | ||||||
|  |   m_NavMeshLayer: 0 | ||||||
|  |   m_StaticEditorFlags: 0 | ||||||
|  |   m_IsActive: 1 | ||||||
|  | --- !u!4 &5021921342190399731 | ||||||
|  | Transform: | ||||||
|  |   m_ObjectHideFlags: 0 | ||||||
|  |   m_CorrespondingSourceObject: {fileID: 0} | ||||||
|  |   m_PrefabInstance: {fileID: 0} | ||||||
|  |   m_PrefabAsset: {fileID: 0} | ||||||
|  |   m_GameObject: {fileID: 3649358604728444914} | ||||||
|  |   m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} | ||||||
|  |   m_LocalPosition: {x: 0, y: -0.274, z: 0.7} | ||||||
|  |   m_LocalScale: {x: 1, y: 1, z: 1} | ||||||
|  |   m_Children: [] | ||||||
|  |   m_Father: {fileID: 6272346181657429396} | ||||||
|  |   m_RootOrder: 0 | ||||||
|  |   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} | ||||||
| --- !u!1 &4824770690127859843 | --- !u!1 &4824770690127859843 | ||||||
| GameObject: | GameObject: | ||||||
|   m_ObjectHideFlags: 0 |   m_ObjectHideFlags: 0 | ||||||
| @@ -262,12 +323,18 @@ GameObject: | |||||||
|   serializedVersion: 6 |   serializedVersion: 6 | ||||||
|   m_Component: |   m_Component: | ||||||
|   - component: {fileID: 6272346181302961296} |   - component: {fileID: 6272346181302961296} | ||||||
|  |   - component: {fileID: 8191616764201741429} | ||||||
|   - component: {fileID: 6272346181302961295} |   - component: {fileID: 6272346181302961295} | ||||||
|   - component: {fileID: 320375778840406984} |   - component: {fileID: 320375778840406984} | ||||||
|   - component: {fileID: -4574526707603160507} |   - component: {fileID: -4574526707603160507} | ||||||
|   - component: {fileID: 7273209952621479910} |   - component: {fileID: 7273209952621479910} | ||||||
|   - component: {fileID: 4959463831902427506} |   - component: {fileID: 4959463831902427506} | ||||||
|   - component: {fileID: 5630859218361338035} |   - component: {fileID: 5630859218361338035} | ||||||
|  |   - component: {fileID: 8436279266335313624} | ||||||
|  |   - component: {fileID: 3781802212159559521} | ||||||
|  |   - component: {fileID: 6207632454083444980} | ||||||
|  |   - component: {fileID: 1509131218531316230} | ||||||
|  |   - component: {fileID: 268368477457052331} | ||||||
|   m_Layer: 0 |   m_Layer: 0 | ||||||
|   m_Name: Player |   m_Name: Player | ||||||
|   m_TagString: Player |   m_TagString: Player | ||||||
| @@ -293,6 +360,20 @@ Transform: | |||||||
|   m_Father: {fileID: 0} |   m_Father: {fileID: 0} | ||||||
|   m_RootOrder: 0 |   m_RootOrder: 0 | ||||||
|   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} |   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} | ||||||
|  | --- !u!136 &8191616764201741429 | ||||||
|  | CapsuleCollider: | ||||||
|  |   m_ObjectHideFlags: 0 | ||||||
|  |   m_CorrespondingSourceObject: {fileID: 0} | ||||||
|  |   m_PrefabInstance: {fileID: 0} | ||||||
|  |   m_PrefabAsset: {fileID: 0} | ||||||
|  |   m_GameObject: {fileID: 6272346181302961293} | ||||||
|  |   m_Material: {fileID: 0} | ||||||
|  |   m_IsTrigger: 0 | ||||||
|  |   m_Enabled: 1 | ||||||
|  |   m_Radius: 0.3 | ||||||
|  |   m_Height: 1.8 | ||||||
|  |   m_Direction: 1 | ||||||
|  |   m_Center: {x: 0, y: 1, z: 0} | ||||||
| --- !u!143 &6272346181302961295 | --- !u!143 &6272346181302961295 | ||||||
| CharacterController: | CharacterController: | ||||||
|   m_ObjectHideFlags: 0 |   m_ObjectHideFlags: 0 | ||||||
| @@ -345,7 +426,7 @@ MonoBehaviour: | |||||||
|   walkSpeed: 6 |   walkSpeed: 6 | ||||||
|   moveSmoothTime: 0.05 |   moveSmoothTime: 0.05 | ||||||
|   gravity: -10 |   gravity: -10 | ||||||
|   jumpHeight: 1 |   jumpHeight: 0.5 | ||||||
|   groundCheck: {fileID: 6272346182417644039} |   groundCheck: {fileID: 6272346182417644039} | ||||||
|   groundMask: |   groundMask: | ||||||
|     serializedVersion: 2 |     serializedVersion: 2 | ||||||
| @@ -412,7 +493,7 @@ MonoBehaviour: | |||||||
|   m_EditorClassIdentifier:  |   m_EditorClassIdentifier:  | ||||||
|   syncMode: 0 |   syncMode: 0 | ||||||
|   syncInterval: 0.1 |   syncInterval: 0.1 | ||||||
|   playerCamera: {fileID: 6272346181657429396} |   playerCamera: {fileID: 7283872597117707309} | ||||||
|   playerNeck: {fileID: 981273033772084037} |   playerNeck: {fileID: 981273033772084037} | ||||||
|   mouseSensitivity: 4 |   mouseSensitivity: 4 | ||||||
|   maxCameraAngle: 90 |   maxCameraAngle: 90 | ||||||
| @@ -421,6 +502,119 @@ MonoBehaviour: | |||||||
|   neckLength: 0.2 |   neckLength: 0.2 | ||||||
|   mouseSmoothTime: 0.001 |   mouseSmoothTime: 0.001 | ||||||
|   lockCursor: 1 |   lockCursor: 1 | ||||||
|  | --- !u!114 &8436279266335313624 | ||||||
|  | MonoBehaviour: | ||||||
|  |   m_ObjectHideFlags: 0 | ||||||
|  |   m_CorrespondingSourceObject: {fileID: 0} | ||||||
|  |   m_PrefabInstance: {fileID: 0} | ||||||
|  |   m_PrefabAsset: {fileID: 0} | ||||||
|  |   m_GameObject: {fileID: 6272346181302961293} | ||||||
|  |   m_Enabled: 1 | ||||||
|  |   m_EditorHideFlags: 0 | ||||||
|  |   m_Script: {fileID: 11500000, guid: 3317f24e780855847830f5662153b41d, type: 3} | ||||||
|  |   m_Name:  | ||||||
|  |   m_EditorClassIdentifier:  | ||||||
|  |   syncMode: 0 | ||||||
|  |   syncInterval: 0.1 | ||||||
|  |   isAlive: 1 | ||||||
|  |   clientId: 0 | ||||||
|  |   username:  | ||||||
|  |   usernameTextObj: {fileID: 0} | ||||||
|  |   health: 0 | ||||||
|  | --- !u!114 &3781802212159559521 | ||||||
|  | MonoBehaviour: | ||||||
|  |   m_ObjectHideFlags: 0 | ||||||
|  |   m_CorrespondingSourceObject: {fileID: 0} | ||||||
|  |   m_PrefabInstance: {fileID: 0} | ||||||
|  |   m_PrefabAsset: {fileID: 0} | ||||||
|  |   m_GameObject: {fileID: 6272346181302961293} | ||||||
|  |   m_Enabled: 1 | ||||||
|  |   m_EditorHideFlags: 0 | ||||||
|  |   m_Script: {fileID: 11500000, guid: bc5bc2b49bd326e4db460a6a3af59311, type: 3} | ||||||
|  |   m_Name:  | ||||||
|  |   m_EditorClassIdentifier:  | ||||||
|  |   syncMode: 0 | ||||||
|  |   syncInterval: 0.1 | ||||||
|  |   muzzle: {fileID: 3649358604728444914} | ||||||
|  | --- !u!114 &6207632454083444980 | ||||||
|  | MonoBehaviour: | ||||||
|  |   m_ObjectHideFlags: 0 | ||||||
|  |   m_CorrespondingSourceObject: {fileID: 0} | ||||||
|  |   m_PrefabInstance: {fileID: 0} | ||||||
|  |   m_PrefabAsset: {fileID: 0} | ||||||
|  |   m_GameObject: {fileID: 6272346181302961293} | ||||||
|  |   m_Enabled: 1 | ||||||
|  |   m_EditorHideFlags: 0 | ||||||
|  |   m_Script: {fileID: 11500000, guid: 734b48bea0b204338958ee3d885e11f0, type: 3} | ||||||
|  |   m_Name:  | ||||||
|  |   m_EditorClassIdentifier:  | ||||||
|  |   syncMode: 0 | ||||||
|  |   syncInterval: 0.1 | ||||||
|  |   clientAuthority: 1 | ||||||
|  |   sendInterval: 0.05 | ||||||
|  |   syncPosition: 1 | ||||||
|  |   syncRotation: 1 | ||||||
|  |   syncScale: 0 | ||||||
|  |   interpolatePosition: 1 | ||||||
|  |   interpolateRotation: 1 | ||||||
|  |   interpolateScale: 0 | ||||||
|  |   bufferTimeMultiplier: 1 | ||||||
|  |   bufferSizeLimit: 64 | ||||||
|  |   catchupThreshold: 4 | ||||||
|  |   catchupMultiplier: 0.1 | ||||||
|  |   showGizmos: 0 | ||||||
|  |   showOverlay: 0 | ||||||
|  |   overlayColor: {r: 0, g: 0, b: 0, a: 0.5} | ||||||
|  |   target: {fileID: 6272346181657429396} | ||||||
|  | --- !u!114 &1509131218531316230 | ||||||
|  | MonoBehaviour: | ||||||
|  |   m_ObjectHideFlags: 0 | ||||||
|  |   m_CorrespondingSourceObject: {fileID: 0} | ||||||
|  |   m_PrefabInstance: {fileID: 0} | ||||||
|  |   m_PrefabAsset: {fileID: 0} | ||||||
|  |   m_GameObject: {fileID: 6272346181302961293} | ||||||
|  |   m_Enabled: 1 | ||||||
|  |   m_EditorHideFlags: 0 | ||||||
|  |   m_Script: {fileID: 11500000, guid: 734b48bea0b204338958ee3d885e11f0, type: 3} | ||||||
|  |   m_Name:  | ||||||
|  |   m_EditorClassIdentifier:  | ||||||
|  |   syncMode: 0 | ||||||
|  |   syncInterval: 0.1 | ||||||
|  |   clientAuthority: 1 | ||||||
|  |   sendInterval: 0.05 | ||||||
|  |   syncPosition: 1 | ||||||
|  |   syncRotation: 1 | ||||||
|  |   syncScale: 0 | ||||||
|  |   interpolatePosition: 1 | ||||||
|  |   interpolateRotation: 1 | ||||||
|  |   interpolateScale: 0 | ||||||
|  |   bufferTimeMultiplier: 1 | ||||||
|  |   bufferSizeLimit: 64 | ||||||
|  |   catchupThreshold: 4 | ||||||
|  |   catchupMultiplier: 0.1 | ||||||
|  |   showGizmos: 0 | ||||||
|  |   showOverlay: 0 | ||||||
|  |   overlayColor: {r: 0, g: 0, b: 0, a: 0.5} | ||||||
|  |   target: {fileID: 981273033772084037} | ||||||
|  | --- !u!114 &268368477457052331 | ||||||
|  | MonoBehaviour: | ||||||
|  |   m_ObjectHideFlags: 0 | ||||||
|  |   m_CorrespondingSourceObject: {fileID: 0} | ||||||
|  |   m_PrefabInstance: {fileID: 0} | ||||||
|  |   m_PrefabAsset: {fileID: 0} | ||||||
|  |   m_GameObject: {fileID: 6272346181302961293} | ||||||
|  |   m_Enabled: 0 | ||||||
|  |   m_EditorHideFlags: 0 | ||||||
|  |   m_Script: {fileID: 11500000, guid: 4db7caf602ce379408a59c8722e06e46, type: 3} | ||||||
|  |   m_Name:  | ||||||
|  |   m_EditorClassIdentifier:  | ||||||
|  |   syncMode: 0 | ||||||
|  |   syncInterval: 0.1 | ||||||
|  |   posCheckDistance: 1 | ||||||
|  |   checkDist: 0 | ||||||
|  |   stepAmplitude: 1 | ||||||
|  |   stepFrequency: 0.001 | ||||||
|  |   Neck: {fileID: 6272346181657429396} | ||||||
| --- !u!1 &6272346181657429393 | --- !u!1 &6272346181657429393 | ||||||
| GameObject: | GameObject: | ||||||
|   m_ObjectHideFlags: 0 |   m_ObjectHideFlags: 0 | ||||||
| @@ -432,7 +626,7 @@ GameObject: | |||||||
|   - component: {fileID: 6272346181657429396} |   - component: {fileID: 6272346181657429396} | ||||||
|   - component: {fileID: 6272346181657429395} |   - component: {fileID: 6272346181657429395} | ||||||
|   m_Layer: 0 |   m_Layer: 0 | ||||||
|   m_Name: Main Camera |   m_Name: Camera | ||||||
|   m_TagString: MainCamera |   m_TagString: MainCamera | ||||||
|   m_Icon: {fileID: 0} |   m_Icon: {fileID: 0} | ||||||
|   m_NavMeshLayer: 0 |   m_NavMeshLayer: 0 | ||||||
| @@ -445,11 +639,12 @@ Transform: | |||||||
|   m_PrefabInstance: {fileID: 0} |   m_PrefabInstance: {fileID: 0} | ||||||
|   m_PrefabAsset: {fileID: 0} |   m_PrefabAsset: {fileID: 0} | ||||||
|   m_GameObject: {fileID: 6272346181657429393} |   m_GameObject: {fileID: 6272346181657429393} | ||||||
|   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.28639913, y: 0.444623, z: -0.48100734} | ||||||
|   m_LocalScale: {x: 1, y: 1, z: 1} |   m_LocalScale: {x: 1, y: 1, z: 1} | ||||||
|   m_Children: [] |   m_Children: | ||||||
|   m_Father: {fileID: 981273033772084037} |   - {fileID: 5021921342190399731} | ||||||
|  |   m_Father: {fileID: 7283872597117707309} | ||||||
|   m_RootOrder: 0 |   m_RootOrder: 0 | ||||||
|   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} |   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} | ||||||
| --- !u!20 &6272346181657429395 | --- !u!20 &6272346181657429395 | ||||||
| @@ -552,7 +747,7 @@ Transform: | |||||||
|   m_LocalPosition: {x: 0, y: 2.01, z: 0} |   m_LocalPosition: {x: 0, y: 2.01, z: 0} | ||||||
|   m_LocalScale: {x: 1, y: 1, z: 1} |   m_LocalScale: {x: 1, y: 1, z: 1} | ||||||
|   m_Children: |   m_Children: | ||||||
|   - {fileID: 6272346181657429396} |   - {fileID: 7283872597117707309} | ||||||
|   - {fileID: 4399039561386292163} |   - {fileID: 4399039561386292163} | ||||||
|   m_Father: {fileID: 6272346181302961296} |   m_Father: {fileID: 6272346181302961296} | ||||||
|   m_RootOrder: 3 |   m_RootOrder: 3 | ||||||
|   | |||||||
							
								
								
									
										48
									
								
								Assets/Scripts/Player/Headbob.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										48
									
								
								Assets/Scripts/Player/Headbob.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,48 @@ | |||||||
|  | using System.Collections; | ||||||
|  | using System.Collections.Generic; | ||||||
|  | using UnityEngine; | ||||||
|  | using Mirror; | ||||||
|  | public class Headbob : NetworkBehaviour | ||||||
|  | { | ||||||
|  |     [SerializeField] private float posCheckDistance = 0.01f; | ||||||
|  |     [SerializeField] private float checkDist = 0.0f; | ||||||
|  |  | ||||||
|  |     [Header("Step Settings")] | ||||||
|  |     [SerializeField] private float stepAmplitude; | ||||||
|  |     [SerializeField] private float stepFrequency; | ||||||
|  |     [SerializeField] private Transform Neck; | ||||||
|  |  | ||||||
|  |     private Vector3 lastPos; | ||||||
|  |     private float oldDist = 0; | ||||||
|  |     private void Start() | ||||||
|  |     { | ||||||
|  |         lastPos = this.transform.position; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     private void Update() | ||||||
|  |     { | ||||||
|  |         float dist = Vector3.Distance(lastPos, this.transform.position); | ||||||
|  |          | ||||||
|  |          | ||||||
|  |         if (dist > posCheckDistance) | ||||||
|  |         { | ||||||
|  |             checkDist += dist - oldDist; | ||||||
|  |             lastPos = this.transform.position; | ||||||
|  |             oldDist = dist; | ||||||
|  |         } | ||||||
|  |         if (checkDist > 2) | ||||||
|  |         { | ||||||
|  |             checkDist = 0; | ||||||
|  |         } | ||||||
|  |         Vector3 newPos = new Vector3(Neck.transform.position.x,getSin(stepAmplitude,stepAmplitude,checkDist),Neck.transform.position.z); | ||||||
|  |         Neck.position = newPos; | ||||||
|  |         Debug.Log("Distance: " + checkDist + ", Sin " + getSin(stepAmplitude, stepAmplitude, checkDist)); | ||||||
|  |          | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     private float getSin(float multiplier, float devisor,float x) | ||||||
|  |     { | ||||||
|  |         return multiplier * Mathf.Sin((x/Mathf.PI)*10); | ||||||
|  |     } | ||||||
|  |      | ||||||
|  | } | ||||||
							
								
								
									
										11
									
								
								Assets/Scripts/Player/Headbob.cs.meta
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								Assets/Scripts/Player/Headbob.cs.meta
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,11 @@ | |||||||
|  | fileFormatVersion: 2 | ||||||
|  | guid: 4db7caf602ce379408a59c8722e06e46 | ||||||
|  | MonoImporter: | ||||||
|  |   externalObjects: {} | ||||||
|  |   serializedVersion: 2 | ||||||
|  |   defaultReferences: [] | ||||||
|  |   executionOrder: 0 | ||||||
|  |   icon: {instanceID: 0} | ||||||
|  |   userData:  | ||||||
|  |   assetBundleName:  | ||||||
|  |   assetBundleVariant:  | ||||||
| @@ -5,23 +5,33 @@ using Mirror; | |||||||
|  |  | ||||||
| public class Player : NetworkBehaviour | public class Player : NetworkBehaviour | ||||||
| { | { | ||||||
|     public bool isAlive; |     public bool isAlive = true; | ||||||
|     public Team team; |     public Team team; | ||||||
|     [SerializeField] private const int defaultHp = 100; |     [SerializeField] private const int defaultHp = 100; | ||||||
|  |  | ||||||
|  |  | ||||||
|     public ulong clientId; |     public ulong clientId; | ||||||
|  |  | ||||||
|     [SyncVar(hook = nameof(SetName))] |     [SyncVar(hook = nameof(SetName))]  | ||||||
|     public string username; |     public string username; | ||||||
|  |  | ||||||
|     [SerializeField] GameObject usernameTextObj; |     [SerializeField] GameObject usernameTextObj; | ||||||
|  |  | ||||||
|     private int health; |     [SerializeField] [SyncVar]public int health = 100; | ||||||
|     private int kills; |     private int kills; | ||||||
|     private int deaths; |     private int deaths; | ||||||
|  |  | ||||||
|  |     private void Start() | ||||||
|  |     { | ||||||
|  |         if (isServer)  | ||||||
|  |         { | ||||||
|  |             health = defaultHp; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|     public override void OnStartLocalPlayer() |     public override void OnStartLocalPlayer() | ||||||
|     { |     { | ||||||
|         base.OnStartClient(); |         base.OnStartClient(); | ||||||
|  |          | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public void SetName(string oldName, string newName) |     public void SetName(string oldName, string newName) | ||||||
| @@ -56,8 +66,11 @@ public class Player : NetworkBehaviour | |||||||
|     } |     } | ||||||
|     public void RemoveHealth(int value) |     public void RemoveHealth(int value) | ||||||
|     { |     { | ||||||
|  |  | ||||||
|  |          | ||||||
|         if (isAlive) |         if (isAlive) | ||||||
|         { |         { | ||||||
|  |             Debug.Log("yeet" + value); | ||||||
|             health -= value; |             health -= value; | ||||||
|             if (health <= 0) |             if (health <= 0) | ||||||
|             { |             { | ||||||
|   | |||||||
| @@ -84,7 +84,6 @@ public class PlayerController : NetworkBehaviour | |||||||
|             } |             } | ||||||
|  |  | ||||||
|             groundAngle = Vector3.Angle(hit.normal,transform.up); |             groundAngle = Vector3.Angle(hit.normal,transform.up); | ||||||
|             Debug.Log(moveGroundAngle); |  | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|     private void Sprint()  |     private void Sprint()  | ||||||
| @@ -118,7 +117,7 @@ public class PlayerController : NetworkBehaviour | |||||||
|         if (Input.GetButtonDown("Jump") && isGrounded) |         if (Input.GetButtonDown("Jump") && isGrounded) | ||||||
|         { |         { | ||||||
|             //Debug.Log("Jump"); |             //Debug.Log("Jump"); | ||||||
|             velocityY += Mathf.Sqrt(jumpHeight * 4f); |             velocityY += Mathf.Sqrt(jumpHeight * -2f * gravity); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         inputDirection = new Vector3(Input.GetAxisRaw("Horizontal"),0, Input.GetAxisRaw("Vertical")); //Get Inputs |         inputDirection = new Vector3(Input.GetAxisRaw("Horizontal"),0, Input.GetAxisRaw("Vertical")); //Get Inputs | ||||||
|   | |||||||
| @@ -37,6 +37,7 @@ public class PlayerMouseLook : NetworkBehaviour | |||||||
|  |  | ||||||
|             playerCamera.gameObject.SetActive(true); |             playerCamera.gameObject.SetActive(true); | ||||||
|  |  | ||||||
|  |  | ||||||
|             if (lockCursor) |             if (lockCursor) | ||||||
|             { |             { | ||||||
|                 Cursor.lockState = CursorLockMode.Locked; |                 Cursor.lockState = CursorLockMode.Locked; | ||||||
|   | |||||||
							
								
								
									
										69
									
								
								Assets/Scripts/Weapons/Shoot.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										69
									
								
								Assets/Scripts/Weapons/Shoot.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,69 @@ | |||||||
|  | using System.Collections; | ||||||
|  | using System.Collections.Generic; | ||||||
|  | using UnityEngine; | ||||||
|  | using Mirror; | ||||||
|  |  | ||||||
|  | public class Shoot : NetworkBehaviour | ||||||
|  | { | ||||||
|  |     [SerializeField] GameObject muzzle; | ||||||
|  |  | ||||||
|  |     private void Start() | ||||||
|  |     { | ||||||
|  |  | ||||||
|  |     } | ||||||
|  |     private void Update() | ||||||
|  |     { | ||||||
|  |         if (isLocalPlayer) | ||||||
|  |         { | ||||||
|  |             if (Input.GetKeyDown(KeyCode.Mouse0)) | ||||||
|  |             { | ||||||
|  |                 //CmdFireBullet(); | ||||||
|  |                 RpcOnFire(); | ||||||
|  |                 Debug.Log("Hit Left Mouse  "); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |     private void OnDrawGizmos() | ||||||
|  |     { | ||||||
|  |  | ||||||
|  |         if (!Input.GetKeyDown(KeyCode.Mouse0)) | ||||||
|  |         { | ||||||
|  |             Gizmos.color = Color.red; | ||||||
|  |         } | ||||||
|  |         else  | ||||||
|  |         { | ||||||
|  |             Gizmos.color = Color.green; | ||||||
|  |         } | ||||||
|  |         Gizmos.DrawRay(muzzle.transform.position, muzzle.transform.forward); | ||||||
|  |  | ||||||
|  |     } | ||||||
|  |      | ||||||
|  |     [Command] | ||||||
|  |     // This code will be executed on the server. | ||||||
|  |     private void CmdFireBullet() | ||||||
|  |     { | ||||||
|  |         GameObject dedplayer; | ||||||
|  |         RaycastHit hit; | ||||||
|  |         if (Physics.Raycast(muzzle.transform.position, muzzle.transform.forward, out hit)) | ||||||
|  |         { | ||||||
|  |  | ||||||
|  |             if (hit.transform.gameObject.GetComponent<Player>() != null) | ||||||
|  |             { | ||||||
|  |                 Debug.Log("Hit player:  " + hit.transform.gameObject.name); | ||||||
|  |                 dedplayer = hit.transform.gameObject; | ||||||
|  |                 //dedplayer.GetComponent<Player>().health -= 20; | ||||||
|  |                 dedplayer.GetComponent<Player>().RemoveHealth(20); | ||||||
|  |  | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |  | ||||||
|  |     [Client] | ||||||
|  |     // This code will be executed on the Client. | ||||||
|  |     void RpcOnFire() | ||||||
|  |     { | ||||||
|  |         CmdFireBullet(); | ||||||
|  |  | ||||||
|  |     } | ||||||
|  | } | ||||||
							
								
								
									
										11
									
								
								Assets/Scripts/Weapons/Shoot.cs.meta
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								Assets/Scripts/Weapons/Shoot.cs.meta
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,11 @@ | |||||||
|  | fileFormatVersion: 2 | ||||||
|  | guid: bc5bc2b49bd326e4db460a6a3af59311 | ||||||
|  | MonoImporter: | ||||||
|  |   externalObjects: {} | ||||||
|  |   serializedVersion: 2 | ||||||
|  |   defaultReferences: [] | ||||||
|  |   executionOrder: 0 | ||||||
|  |   icon: {instanceID: 0} | ||||||
|  |   userData:  | ||||||
|  |   assetBundleName:  | ||||||
|  |   assetBundleVariant:  | ||||||
| @@ -99,7 +99,7 @@ PlayerSettings: | |||||||
|   xboxEnableFitness: 0 |   xboxEnableFitness: 0 | ||||||
|   visibleInBackground: 1 |   visibleInBackground: 1 | ||||||
|   allowFullscreenSwitch: 1 |   allowFullscreenSwitch: 1 | ||||||
|   fullscreenMode: 2 |   fullscreenMode: 3 | ||||||
|   xboxSpeechDB: 0 |   xboxSpeechDB: 0 | ||||||
|   xboxEnableHeadOrientation: 0 |   xboxEnableHeadOrientation: 0 | ||||||
|   xboxEnableGuest: 0 |   xboxEnableGuest: 0 | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 juliuse98
					juliuse98