This commit is contained in:
2021-11-13 18:59:45 +05:30
parent 6316312962
commit 3560ff1ef7
224 changed files with 177260 additions and 14466 deletions

View File

@@ -0,0 +1,17 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ArmsPosition : MonoBehaviour
{
public Transform leftHand;
public Transform rightHand;
public Vector3 leftHandOffset;
public Vector3 leftHandRotation;
void Update()
{
leftHandOffset = rightHand.InverseTransformPoint(leftHand.position);
leftHandRotation= leftHand.eulerAngles;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 70a549dd3d38bb466a4fbd72518715ba
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 2676f6aa8936d49aabb2c31468e23f76
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,15 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using EasyButtons;
public class MeshCombine : MonoBehaviour
{
public SkinnedMeshRenderer target;
public SkinnedMeshRenderer src;
public Transform[] bones;
[Button]
void Recalculate(){
target.rootBone = src.rootBone;
target.bones = src.bones;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a1348700687eb9512972b49aaa2eeb95
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,264 @@
using UnityEngine;
using System.Collections.Generic;
using HierarchyDict = System.Collections.Generic.Dictionary<string, UnityEngine.Transform>;
using BoneTransformDict = System.Collections.Generic.Dictionary<string, utils.Tuple<UnityEngine.Transform, string>>;
namespace utils
{
public class MeshCombiner
{
#region Operations
//! Combine mesh.
/*!
\return combined mesh instance.
*/
public static GameObject Combine(List<SkinnedMeshRenderer> SkinnedRenderers)
{
// Generated GO
GameObject final_mesh_go = new GameObject("Mesh");
// Dummy parent holder
GameObject dummy_parent = new GameObject("DummyParent");
// All available bones
var all_bones = new BoneTransformDict();
// Traverse through all skinned mesh renderers
foreach(var renderer in SkinnedRenderers)
{
var renderer_bones = renderer.bones;
foreach (var bone in renderer_bones)
{
// Bone doesn't exist, add it
if (!all_bones.ContainsKey(bone.name))
all_bones[bone.name] = new utils.Tuple<Transform, string>(bone, bone.parent.name);
}
}
var combineInstanceArrays = new Dictionary<Material, List<CombineInstance>>();
var bone_weights = new Dictionary<Mesh, BoneWeight[]>();
// Map between bone name and index
var added_bones = new Dictionary<string, int>();
// List of child objects holding the skinned mesh renderers to be
// destroyed when finished
var child_objects_to_destroy = new List<GameObject>();
int bone_index = 0;
foreach(var renderer in SkinnedRenderers)
{
child_objects_to_destroy.Add(renderer.transform.parent.gameObject);
var renderer_bones = renderer.bones;
// Add all bones as first and save the indices of them
foreach (var bone in renderer_bones)
{
// Bone not yet added
if (!added_bones.ContainsKey(bone.name))
added_bones[bone.name] = bone_index++;
}
// Adjust bone weights indices based on real indices of bones
var bone_weights_list = new BoneWeight[renderer.sharedMesh.boneWeights.Length];
var renderer_bone_weights = renderer.sharedMesh.boneWeights;
for (int i = 0; i < renderer_bone_weights.Length; ++i)
{
BoneWeight current_bone_weight = renderer_bone_weights[i];
current_bone_weight.boneIndex0 = added_bones[renderer_bones[current_bone_weight.boneIndex0].name];
current_bone_weight.boneIndex2 = added_bones[renderer_bones[current_bone_weight.boneIndex2].name];
current_bone_weight.boneIndex3 = added_bones[renderer_bones[current_bone_weight.boneIndex3].name];
current_bone_weight.boneIndex1 = added_bones[renderer_bones[current_bone_weight.boneIndex1].name];
bone_weights_list[i] = current_bone_weight;
}
bone_weights[renderer.sharedMesh] = bone_weights_list;
// Handle bad input
if (renderer.sharedMaterials.Length != renderer.sharedMesh.subMeshCount)
{
Debug.LogError("Mismatch between material count and submesh count. Is this the correct MeshRenderer?");
continue;
}
// Prepare stuff for mesh combination with same materials
for (int i = 0; i < renderer.sharedMesh.subMeshCount; i++)
{
// Material not in dict, add it
if (!combineInstanceArrays.ContainsKey(renderer.sharedMaterials[i]))
combineInstanceArrays[renderer.sharedMaterials[i]] = new List<CombineInstance>();
var actual_mat_list = combineInstanceArrays[renderer.sharedMaterials[i]];
// Add new instance
var combine_instance = new CombineInstance();
combine_instance.transform = renderer.transform.localToWorldMatrix;
combine_instance.subMeshIndex = i;
combine_instance.mesh = renderer.sharedMesh;
actual_mat_list.Add(combine_instance);
}
// No need to use it anymore
renderer.enabled = false;
}
var bones_hierarchy = new HierarchyDict();
// Recreate bone structure
foreach (var bone in all_bones)
{
// Bone not processed, process it
if (!bones_hierarchy.ContainsKey(bone.Key))
AddParent(bone.Key, bones_hierarchy, all_bones, dummy_parent);
}
// Create bone array from preprocessed dict
var bones = new Transform[added_bones.Count];
foreach (var bone in added_bones)
bones[bone.Value] = bones_hierarchy[bone.Key];
// Get the root bone
Transform root_bone = bones[0];
while (root_bone.parent != null)
{
// Get parent
if (bones_hierarchy.ContainsKey(root_bone.parent.name))
root_bone = root_bone.parent;
else
break;
}
// Create skinned mesh renderer GO
GameObject combined_mesh_go = new GameObject("Combined");
combined_mesh_go.transform.parent = final_mesh_go.transform;
combined_mesh_go.transform.localPosition = Vector3.zero;
// Fill bind poses
var bind_poses = new Matrix4x4[bones.Length];
for (int i = 0; i < bones.Length; ++i)
bind_poses[i] = bones[i].worldToLocalMatrix * combined_mesh_go.transform.localToWorldMatrix;
// Need to move it to new GO
root_bone.parent = final_mesh_go.transform;
// Combine meshes into one
var combined_new_mesh = new Mesh();
var combined_vertices = new List<Vector3>();
var combined_uvs = new List<Vector2>();
var combined_indices = new List<int[]>();
var combined_bone_weights = new List<BoneWeight>();
var combined_materials = new Material[combineInstanceArrays.Count];
var vertex_offset_map = new Dictionary<Mesh, int>();
int vertex_index_offset = 0;
int current_material_index = 0;
foreach (var combine_instance in combineInstanceArrays)
{
combined_materials[current_material_index++] = combine_instance.Key;
var submesh_indices = new List<int>();
// Process meshes for each material
foreach (var combine in combine_instance.Value)
{
// Update vertex offset for current mesh
if (!vertex_offset_map.ContainsKey(combine.mesh))
{
// Add vertices for mesh
combined_vertices.AddRange(combine.mesh.vertices);
// Set uvs
combined_uvs.AddRange(combine.mesh.uv);
// Add weights
combined_bone_weights.AddRange(bone_weights[combine.mesh]);
vertex_offset_map[combine.mesh] = vertex_index_offset;
vertex_index_offset += combine.mesh.vertexCount;
}
int vertex_current_offset = vertex_offset_map[combine.mesh];
var indices = combine.mesh.GetTriangles(combine.subMeshIndex);
// Need to "shift" indices
for (int k = 0; k < indices.Length; ++k)
indices[k] += vertex_current_offset;
submesh_indices.AddRange(indices);
}
// Push indices for given submesh
combined_indices.Add(submesh_indices.ToArray());
}
combined_new_mesh.vertices = combined_vertices.ToArray();
combined_new_mesh.uv = combined_uvs.ToArray();
combined_new_mesh.boneWeights = combined_bone_weights.ToArray();
combined_new_mesh.subMeshCount = combined_materials.Length;
for (int i = 0; i < combined_indices.Count; ++i)
combined_new_mesh.SetTriangles(combined_indices[i], i);
// Create mesh renderer
SkinnedMeshRenderer combined_skin_mesh_renderer = combined_mesh_go.AddComponent<SkinnedMeshRenderer>();
combined_skin_mesh_renderer.sharedMesh = combined_new_mesh;
combined_skin_mesh_renderer.bones = bones;
combined_skin_mesh_renderer.rootBone = root_bone;
combined_skin_mesh_renderer.sharedMesh.bindposes = bind_poses;
combined_skin_mesh_renderer.sharedMesh.RecalculateNormals();
combined_skin_mesh_renderer.sharedMesh.RecalculateBounds();
combined_skin_mesh_renderer.sharedMaterials = combined_materials;
// Destroy children
foreach (var child in child_objects_to_destroy)
GameObject.DestroyImmediate(child);
// Destroy dummy parent
GameObject.DestroyImmediate(dummy_parent);
return final_mesh_go;
}
static void AddParent(string BoneName, HierarchyDict BoneHierarchy, BoneTransformDict AllBones, GameObject DummyParent)
{
Transform actual_bone = null;
// Must be bone
if (AllBones.ContainsKey(BoneName))
{
var bone_tuple = AllBones[BoneName];
// Add parent recursively if not added
if (!BoneHierarchy.ContainsKey(bone_tuple._2))
{
AddParent(bone_tuple._2, BoneHierarchy, AllBones, DummyParent);
// Unparent all children of parents
Unparent(BoneHierarchy[bone_tuple._2], DummyParent);
}
bone_tuple._1.parent = BoneHierarchy[bone_tuple._2];
actual_bone = bone_tuple._1;
}
BoneHierarchy[BoneName] = actual_bone;
}
static void Unparent(Transform Parent, GameObject DummyParent)
{
if (Parent != null)
{
var unparent_list = new List<Transform>();
foreach (Transform child in Parent.transform)
unparent_list.Add(child);
foreach (var child in unparent_list)
child.parent = DummyParent.transform;
}
}
#endregion
}
public struct Tuple<T1, T2>
{
public readonly T1 _1;
public readonly T2 _2;
public Tuple(T1 T1_, T2 T2_)
{
_1 = T1_;
_2 = T2_;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 41a1c1b962971715da1b4f1ab4cb1ff0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,30 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using EasyButtons;
public class bulkRenamer : MonoBehaviour
{
public string find;
public string replace;
[Button]
public void Rename(){
foreach(Transform t in transform.GetComponentsInChildren<Transform>()){
if(t.name.Contains(find)){
t.name = t.name.Replace(find,replace);
}
}
Debug.Log("It works!");
}
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c5e3ded547a12bfc3b021afa841c08c4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -259,7 +259,8 @@ PlayerPrefs.SetInt("particles", option);
textureQ.value = PlayerPrefs.GetInt("textureQ");
meshQ.value = PlayerPrefs.GetInt("meshQ");
lightningQ.value = PlayerPrefs.GetInt("lightningQ");
resolution.SetValue(resolution.GetOption(PlayerPrefs.GetString("resolution")));
Debug.Log(PlayerPrefs.GetString("resolution"));
// resolution.SetValue(resolution.GetOption(PlayerPrefs.GetString("resolution")));
//APPLY EACH
QualitySettings.vSyncCount = PlayerPrefs.GetInt("vsync");
@@ -356,8 +357,8 @@ PlayerPrefs.SetInt("particles", option);
Screen.fullScreen = fullscreen.isOn;
string[] res = PlayerPrefs.GetString("resolution").Split('x');
Screen.SetResolution(int.Parse(res[0]), int.Parse(res[1]), fullscreen.isOn);
// string[] res = PlayerPrefs.GetString("resolution").Split('x');
// Screen.SetResolution(int.Parse(res[0]), int.Parse(res[1]), fullscreen.isOn);
}

View File

@@ -5,15 +5,5 @@ using UnityEngine;
public class meleeWeaponData : MonoBehaviour
{
public string weaponName;
void Start()
{
}
// Update is called once per frame
void Update()
{
}
public string animName;
}

View File

@@ -1,4 +1,4 @@
using System.Collections;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using HQFPSWeapons;
@@ -28,6 +28,8 @@ public class netPlayer : NetworkBehaviour
public meleeWeaponData[] melees;
[SyncVar(hook = nameof(OnEquipmentChanged))]
public int curGunIndex = -1;
[SyncVar(hook = nameof(OnMeleeChanged))]
public int meleeIndex = -1;
public bool holdingRifle;
public Rig leftArm;
public Rig rightArm;
@@ -48,9 +50,12 @@ public class netPlayer : NetworkBehaviour
public Rig headRig;
public Rig chestRig;
public bool showLocalChar;
void Start()
{
if (!isLocalPlayer) { return; } //stuff only for local player
netPlayerStats.localPlayer = this;
@@ -72,13 +77,13 @@ public class netPlayer : NetworkBehaviour
RpcUpdateName(pname);
}
// hideTpsCharacter();
if (!showLocalChar) hideTpsCharacter();
// transform.GetChild(0).gameObject.SetActive(false);
//prepare listeners
player.EquippedItem.AddChangeListener((SaveableItem item) => { callChangeEquipment((item == null) ? "" : item.Name); });
player.UseContinuously.AddListener(() => { Debug.Log("Using Continously"); });
player.UseOnce.AddListener(() => { Debug.Log("Used once"); });
player.UseContinuously.AddListener(() => { onUsedItem(); });
player.UseOnce.AddListener(() => { onUsedItem(); });
player.Aim.AddStartListener(() => { callToggleAim(true); });
player.Aim.AddStopListener(() => { callToggleAim(false); });
@@ -134,7 +139,7 @@ public class netPlayer : NetworkBehaviour
{
//updatePlayerDirection (Regardless of isLocalPlayer)
headRig.weight = (anim.GetBool("running")) ? 0: 1;
// headRig.weight = (anim.GetBool("running")) ? 0: 1;
if (isLocalPlayer)
{//Stuff only for local player
@@ -151,17 +156,18 @@ public class netPlayer : NetworkBehaviour
}
yAxis = player.LookDirection.Val.y;
float lookSmoothness = 0.1f;
if (yAxis == 0)
{
aimHeightTarget.position = aimHeightMid.position;
aimHeightTarget.position = Vector3.Lerp(aimHeightTarget.position, aimHeightMid.position, lookSmoothness);
}
else if (yAxis > 0)
{
aimHeightTarget.position = aimHeightMid.position + ((aimHeightTDC.position - aimHeightMid.position) * yAxis);
aimHeightTarget.position = Vector3.Lerp(aimHeightTarget.position, aimHeightMid.position + ((aimHeightTDC.position - aimHeightMid.position) * yAxis), lookSmoothness);
}
else if (yAxis < 0)
{
aimHeightTarget.position = aimHeightMid.position + ((aimHeightBDC.position - aimHeightMid.position) * -yAxis);
aimHeightTarget.position = Vector3.Lerp(aimHeightTarget.position, aimHeightMid.position + ((aimHeightBDC.position - aimHeightMid.position) * -yAxis), lookSmoothness);
}
anim.SetFloat("vX", Input.GetAxis("Horizontal"));
anim.SetFloat("vY", Input.GetAxis("Vertical"));
@@ -189,6 +195,11 @@ public class netPlayer : NetworkBehaviour
}
CallChangeAnim(animCode);
if (curGunIndex >= 0)
{
// leftHandTarget.position = weaponAim.TransformPoint(-player.GetComponent<ArmsPosition>().leftHandOffset) + (0.35f * leftHandTarget.right);
}
}
else
{//update for other peoples
@@ -197,13 +208,13 @@ public class netPlayer : NetworkBehaviour
}
if (curGunIndex >= 0)
{
leftHandTarget.position = guns[curGunIndex].leftHandPosition.position;
leftHandTarget.rotation = guns[curGunIndex].leftHandPosition.rotation;
// leftHandTarget.position = guns[curGunIndex].leftHandPosition.position;
// leftHandTarget.rotation = guns[curGunIndex].leftHandPosition.rotation;
headTarget.position = guns[curGunIndex].headTarget.position;
@@ -212,7 +223,7 @@ public class netPlayer : NetworkBehaviour
if (bodyWeights <= 1)
{
bodyWeights += 0.5f;
// headRig.weight = bodyWeights;
headRig.weight = bodyWeights;
chestRig.weight = bodyWeights;
}
@@ -221,10 +232,11 @@ public class netPlayer : NetworkBehaviour
}
else
{
if (bodyWeights >= 0 )
if (bodyWeights >= 0)
{
bodyWeights -= 0.05f;
// if(anim.GetBool("running")){headRig.weight = bodyWeights;}
//if (anim.GetBool("running")) { headRig.weight = bodyWeights; }
headRig.weight = bodyWeights;
chestRig.weight = bodyWeights;
}
@@ -290,7 +302,7 @@ public class netPlayer : NetworkBehaviour
{
if (isServer)
{
aiming=value;
aiming = value;
}
else
{
@@ -298,10 +310,11 @@ public class netPlayer : NetworkBehaviour
}
}
void OnAimChanged(bool oldAim, bool newAim){
void OnAimChanged(bool oldAim, bool newAim)
{
if (newAim)
{
// headRig.weight = 1;
// headRig.weight = 1;
chestRig.weight = 1;
weaponAim.position = guns[curGunIndex].aiming_rightHandPosition.position;
weaponAim.rotation = guns[curGunIndex].aiming_rightHandPosition.rotation;
@@ -309,9 +322,9 @@ public class netPlayer : NetworkBehaviour
else
{
Debug.Log(anim.GetBool("running"));
// headRig.weight =(anim.GetBool("running")) ?0 : 1;
chestRig.weight = (anim.GetBool("running")) ?0 : 1;;
// headRig.weight =(anim.GetBool("running")) ?0 : 1;
chestRig.weight = (anim.GetBool("running")) ? 0 : 1; ;
weaponAim.position = guns[curGunIndex].holding_rightHandPosition.position;
weaponAim.rotation = guns[curGunIndex].holding_rightHandPosition.rotation;
}
@@ -320,7 +333,7 @@ public class netPlayer : NetworkBehaviour
[Command]
void CmdToggleAim(bool value)
{
aiming=value;
aiming = value;
}
/*
Animation Codes
@@ -365,10 +378,11 @@ public class netPlayer : NetworkBehaviour
public void callChangeEquipment(string name)
{
//Get the id of weapon using name
int gunId = -1;
int _meleeIndex = -1;
if (name == "")
{
callToggleWeaponEquipment(false);
@@ -384,7 +398,8 @@ public class netPlayer : NetworkBehaviour
}
}
if(gunId < 0){
if (gunId < 0)
{
//This means no weapon is there for that name, lets see on melees
ItemData itemData = null;
@@ -392,35 +407,39 @@ public class netPlayer : NetworkBehaviour
if (itemData != null)
{
gunId = (getMeleeWithName(itemData.Name) * -1)+1;
_meleeIndex = getMeleeWithName(itemData.Name);
}
}
//UPDATE IT USING SYNCVAR
if(isServer){
if (isServer)
{
curGunIndex = gunId;
}else{
SetCurGunId(gunId);
meleeIndex = _meleeIndex;
}
else
{
SetCurGunId(gunId, _meleeIndex);
}
}
[Command]
void SetCurGunId(int gunId)
void SetCurGunId(int gunId, int _meleeIndex)
{
curGunIndex = gunId;
meleeIndex = _meleeIndex;
}
void OnEquipmentChanged(int oldIndex, int newIndex)
{
Debug.Log("THE HOOK WORKS : " + newIndex);
//Debug.Log("THE HOOK WORKS : " + newIndex);
if (newIndex >= 0)
{
//not a melee so disable all melees
foreach(meleeWeaponData melee in melees){
melee.gameObject.SetActive(false);
}
foreach (tpsGunData gun in guns)
{
gun.gameObject.SetActive(false);
@@ -431,8 +450,30 @@ public class netPlayer : NetworkBehaviour
}
guns[newIndex].gameObject.SetActive(true);
toggleWeaponEquipment(true);
}else{
}
else
{
toggleWeaponEquipment(false);
}
}
void OnMeleeChanged(int oldIndex, int newIndex)
{
Debug.Log("Melee Hook Works");
foreach (meleeWeaponData melee in melees)
{
melee.gameObject.SetActive(false);
}
if (newIndex >= 0)
{
//some melee weeapon
melees[newIndex].gameObject.SetActive(true);
}
else
{
//bare hands
}
}
@@ -443,6 +484,7 @@ public class netPlayer : NetworkBehaviour
public void callShoot(Vector3 hitPoint, Vector3 hitNormals)
{
callToggleAim(true);
aimHeightTarget.position = aimHeightTarget.position + new Vector3(0, 0.2f, 0);
if (isServer)
{
broadcastShot(hitPoint, hitNormals);
@@ -471,7 +513,7 @@ public class netPlayer : NetworkBehaviour
void broadcastShot(Vector3 hitPoint, Vector3 hitNormals)
{
// SurfaceEffects effect = (SurfaceEffects)Enum.Parse(typeof(SurfaceEffects), effectType);
if(isLocalPlayer){return;}
if (isLocalPlayer && !showLocalChar) { return; }
SurfaceManager.SpawnEffect(0, SurfaceEffects.BulletHit, 1f, hitPoint, Quaternion.LookRotation(hitNormals));
//shootingEffects
@@ -484,6 +526,22 @@ public class netPlayer : NetworkBehaviour
}
void onUsedItem()
{
if (!isLocalPlayer) { return; }
if (curGunIndex < 0)
{
if (meleeIndex >= 0)
{
anim.CrossFadeInFixedTime(melees[meleeIndex].animName, 0.01f);
}
else
{
anim.CrossFadeInFixedTime("punch", 0.01f);
}
}
}
int getWeaponWithName(string name)
{

View File

@@ -0,0 +1,27 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using HQFPSWeapons;
public class redDotBehaviour : MonoBehaviour
{
public Player player;
public Material redDotMaterial;
public weaponAttachmentsMgr attachmentsMgr;
void Start()
{
player.Aim.AddStartListener(OnAimStart);
player.Aim.AddStopListener(OnAimStop);
}
void Update() {
redDotMaterial.color = new Color(redDotMaterial.color.r, redDotMaterial.color.g, redDotMaterial.color.b, attachmentsMgr.aimed);
}
void OnAimStart(){
attachmentsMgr.focus(true);
}
void OnAimStop(){
attachmentsMgr.focus(false);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: de24c860b650213ee9bea7ebe856b25b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -16,6 +16,8 @@ public class weaponAttachmentsMgr : MonoBehaviour
bool aimValue;
[Range(0.00f,1.00f)]
public float aimed;
bool gotScope= false;
void Start()
{
player.EquippedItem.AddChangeListener((SaveableItem item) => { changeAttachments((item == null) ? "" : item.Name); });
@@ -26,7 +28,7 @@ public class weaponAttachmentsMgr : MonoBehaviour
void Update()
{
if(aimValue && aimed < 1){
aimed+=0.05f;depthOfField.focusDistance.value = 0.1f + (0.1f * (1-aimed));
aimed+=0.05f;if(gotScope){depthOfField.focusDistance.value = 0.1f + (0.1f * (1-aimed));}
}else if(!aimValue && aimed > 0){
aimed-=0.05f;depthOfField.focusDistance.value =0.1f + (0.1f * (1-aimed));
}
@@ -42,6 +44,7 @@ public class weaponAttachmentsMgr : MonoBehaviour
bool isSelected = config.weaponName == item;
foreach(GameObject attachment in config.attachments){
attachment.SetActive(isSelected);
if(isSelected)gotScope = attachment.GetComponent<scopeBehaviour>()!=null;
}
}
}

View File

@@ -226,19 +226,22 @@ public class zombieBehaviour : NetworkBehaviour
if (!isServer)
{
CmdDmg(dmg);
}else{
Dmg(dmg);
}
}
[Command(requiresAuthority =false)]
public void CmdDmg(float damage)
{
Dmg(damage);
}
void Dmg(float damage){
health += damage;
chasing = true;
// Debug.Log("shotY : " + damageData.HitPoint.y + " ,chestBottom : " + chestBottom + " ,headBottom" + headBottom);
// Instantiate(bloodPrefab, damageData.HitPoint, Quaternion.Euler(damageData.HitDirection));
if (health < 0)
{
@@ -252,11 +255,13 @@ public class zombieBehaviour : NetworkBehaviour
die();
RpcDie();
}
}
[ClientRpc]
public void RpcDie()
{
if(isServer){return;}
die();
}