add some extra assets FX and SFX
This commit is contained in:
@@ -133,6 +133,81 @@ public class buildPlayer : MonoBehaviour
|
||||
|
||||
bool checkUnpackCharacterPrefabActive;
|
||||
|
||||
bool replacingCharacterModelInRuntimeActive;
|
||||
|
||||
bool applicationisPlaying;
|
||||
|
||||
bool setNewChestUpVectorValueActive;
|
||||
Vector3 newChestUpVectorValue;
|
||||
|
||||
|
||||
public void setNewCharacterModelToReplaceInRuntime (GameObject newObject)
|
||||
{
|
||||
if (newObject == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
newCharacterModel = newObject;
|
||||
|
||||
//assign the new character model and the bones for the mount points manually from its character info
|
||||
}
|
||||
|
||||
public void buildCharacterInRuntime ()
|
||||
{
|
||||
updateApplicationisPlayingValue ();
|
||||
|
||||
replacingCharacterModelInRuntimeActive = true;
|
||||
|
||||
ignoreApplyCharacterSettings = true;
|
||||
|
||||
if (!applicationisPlaying) {
|
||||
checkUnpackCharacterPrefab ();
|
||||
}
|
||||
|
||||
buildCharacter ();
|
||||
|
||||
ignoreApplyCharacterSettings = false;
|
||||
|
||||
replacingCharacterModelInRuntimeActive = false;
|
||||
|
||||
|
||||
//disable the destroy current character model and the usage of character settings
|
||||
|
||||
//it will need that each component that access to the character model gets the info updated
|
||||
|
||||
//the ragdoll creator should be avoided, as each model would have its ragdoll created, the system will check for the
|
||||
//ragdoll elements inside and assign if already exists
|
||||
|
||||
//check for other objects that check for bone references on start, like head collision
|
||||
}
|
||||
|
||||
public void checkElementsBeforeReplacingCharacterModelInRuntime ()
|
||||
{
|
||||
updateApplicationisPlayingValue ();
|
||||
|
||||
if (applicationisPlaying) {
|
||||
GKC_Utils.checkPlayerStates (player);
|
||||
}
|
||||
}
|
||||
|
||||
public void checkElementsAfterReplacingCharacterModelInRuntime ()
|
||||
{
|
||||
updateApplicationisPlayingValue ();
|
||||
|
||||
if (applicationisPlaying) {
|
||||
weaponsManager.resetWeaponsTransformInThirdPersonToPlayerPosition ();
|
||||
|
||||
weaponsManager.resetWeaponsParentToPlayerPosition ();
|
||||
|
||||
weaponsManager.updateWeaponsParentAndLocalPosition ();
|
||||
}
|
||||
|
||||
Transform temporalChestBone = upperBodyRotationManager.getChestTransform ();
|
||||
|
||||
upperBodyRotationManager.calculateCharacterRotationValues ();
|
||||
|
||||
weaponsManager.updateWeaponsParentsInRuntime (temporalChestBone, newModelAnimator);
|
||||
}
|
||||
|
||||
public void buildCharacterByButton ()
|
||||
{
|
||||
@@ -155,23 +230,61 @@ public class buildPlayer : MonoBehaviour
|
||||
void checkUnpackCharacterPrefab ()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
|
||||
currentPlayerComponentsManager = player.GetComponent<playerComponentsManager> ();
|
||||
|
||||
playerControllerManager = currentPlayerComponentsManager.getPlayerController ();
|
||||
|
||||
bool characterIsAI = playerControllerManager.isCharacterUsedByAI ();
|
||||
|
||||
bool checkPrefabResult = false;
|
||||
|
||||
GameObject mainParentGameObject = null;
|
||||
|
||||
if (transform.parent != null) {
|
||||
if (transform.root != null) {
|
||||
GameObject mainParentGameObject = transform.root.gameObject;
|
||||
print ("checking unpack character " + transform.parent.name);
|
||||
|
||||
if (PrefabUtility.GetCorrespondingObjectFromSource (mainParentGameObject)) {
|
||||
//GKC_Utils.setActiveGameObjectInEditorWithoutCheckNull (null);
|
||||
Transform currentTransformRoot = transform.root;
|
||||
|
||||
print ("Character parent is currently a prefab, unpacking before creating new character\n");
|
||||
if (currentTransformRoot != null) {
|
||||
if (characterIsAI) {
|
||||
currentTransformRoot = transform;
|
||||
|
||||
print (PrefabUtility.GetCorrespondingObjectFromSource (mainParentGameObject).name);
|
||||
|
||||
PrefabUtility.UnpackPrefabInstance (mainParentGameObject, PrefabUnpackMode.Completely, InteractionMode.UserAction);
|
||||
} else {
|
||||
print ("Character parent prefab not found, continuing creating new character process\n");
|
||||
print ("character is AI, the root is this object " + currentTransformRoot.name);
|
||||
}
|
||||
}
|
||||
|
||||
print ("checking unpack character " + currentTransformRoot.name);
|
||||
|
||||
mainParentGameObject = currentTransformRoot.gameObject;
|
||||
|
||||
checkPrefabResult = true;
|
||||
}
|
||||
} else {
|
||||
Transform currentTransformRoot = transform.root;
|
||||
|
||||
if (currentTransformRoot != null) {
|
||||
print ("checking unpack character " + currentTransformRoot.name);
|
||||
|
||||
mainParentGameObject = currentTransformRoot.gameObject;
|
||||
|
||||
checkPrefabResult = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (checkPrefabResult && mainParentGameObject != null) {
|
||||
print ("unpack check condition found, checking result");
|
||||
|
||||
if (PrefabUtility.GetCorrespondingObjectFromSource (mainParentGameObject)) {
|
||||
//GKC_Utils.setActiveGameObjectInEditorWithoutCheckNull (null);
|
||||
|
||||
print ("Character parent is currently a prefab, unpacking before creating new character\n");
|
||||
|
||||
print (PrefabUtility.GetCorrespondingObjectFromSource (mainParentGameObject).name);
|
||||
|
||||
PrefabUtility.UnpackPrefabInstance (mainParentGameObject, PrefabUnpackMode.Completely, InteractionMode.UserAction);
|
||||
} else {
|
||||
print ("Character parent prefab not found, continuing creating new character process\n");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -318,12 +431,19 @@ public class buildPlayer : MonoBehaviour
|
||||
(leftToes != null);
|
||||
}
|
||||
|
||||
void updateApplicationisPlayingValue ()
|
||||
{
|
||||
applicationisPlaying = Application.isPlaying;
|
||||
}
|
||||
|
||||
//set all the objects inside the character's body
|
||||
public void buildCharacter ()
|
||||
{
|
||||
updateApplicationisPlayingValue ();
|
||||
|
||||
//it only works in the editor mode, checking the game is not running
|
||||
if (!Application.isPlaying) {
|
||||
if (!assignNewModelManually) {
|
||||
if (!applicationisPlaying || replacingCharacterModelInRuntimeActive) {
|
||||
if (!assignNewModelManually && !replacingCharacterModelInRuntimeActive) {
|
||||
getCharacterBones ();
|
||||
}
|
||||
|
||||
@@ -337,11 +457,13 @@ public class buildPlayer : MonoBehaviour
|
||||
return;
|
||||
}
|
||||
|
||||
print ("\n\n");
|
||||
print ("CREATING NEW CHARACTER");
|
||||
print ("\n\n");
|
||||
if (!applicationisPlaying) {
|
||||
print ("\n\n");
|
||||
print ("CREATING NEW CHARACTER");
|
||||
print ("\n\n");
|
||||
}
|
||||
|
||||
if (assignNewModelManually) {
|
||||
if (assignNewModelManually || replacingCharacterModelInRuntimeActive) {
|
||||
newModelAnimator = newCharacterModel.GetComponent<Animator> ();
|
||||
|
||||
newCharacterModel.transform.position = currentCharacterModel.transform.position;
|
||||
@@ -383,7 +505,11 @@ public class buildPlayer : MonoBehaviour
|
||||
|
||||
playerCOM = IKManager.getIKBodyCOM ();
|
||||
|
||||
currentCharacterModel.transform.SetParent (null);
|
||||
if (replacingCharacterModelInRuntimeActive) {
|
||||
currentCharacterModel.transform.SetParent (transform);
|
||||
} else {
|
||||
currentCharacterModel.transform.SetParent (null);
|
||||
}
|
||||
|
||||
newCharacterModel.transform.SetParent (playerCOM);
|
||||
|
||||
@@ -404,7 +530,9 @@ public class buildPlayer : MonoBehaviour
|
||||
|
||||
setIKUpperBodyComponents ();
|
||||
|
||||
setMapSystemComponents ();
|
||||
if (!replacingCharacterModelInRuntimeActive) {
|
||||
setMapSystemComponents ();
|
||||
}
|
||||
|
||||
setHealthWeakSpots ();
|
||||
|
||||
@@ -418,18 +546,22 @@ public class buildPlayer : MonoBehaviour
|
||||
|
||||
setCharacterCustomizationManager ();
|
||||
|
||||
if (buildPlayerType) {
|
||||
print ("\n\n");
|
||||
if (buildPlayerType && !replacingCharacterModelInRuntimeActive) {
|
||||
if (!applicationisPlaying) {
|
||||
print ("\n\n");
|
||||
|
||||
print ("Creating new player, adding all main managers into scene");
|
||||
print ("Creating new player, adding all main managers into scene");
|
||||
|
||||
print ("\n\n");
|
||||
print ("\n\n");
|
||||
}
|
||||
|
||||
GKC_Utils.addAllMainManagersToScene ();
|
||||
}
|
||||
|
||||
if (ignoreApplyCharacterSettings) {
|
||||
print ("Character settings not applied due to use the manual build with the ignore option active");
|
||||
if (!applicationisPlaying) {
|
||||
print ("Character settings not applied due to use the manual build with the ignore option active");
|
||||
}
|
||||
|
||||
} else {
|
||||
adjustSettings ();
|
||||
@@ -443,7 +575,15 @@ public class buildPlayer : MonoBehaviour
|
||||
checkUnpackCharacterPrefabActive = false;
|
||||
}
|
||||
|
||||
DestroyImmediate (currentCharacterModel);
|
||||
if (replacingCharacterModelInRuntimeActive) {
|
||||
currentCharacterModel.SetActive (false);
|
||||
|
||||
if (applicationisPlaying) {
|
||||
playerControllerManager.resetAnimatorEvenIfFullBodyAwarenessActive ();
|
||||
}
|
||||
} else {
|
||||
DestroyImmediate (currentCharacterModel);
|
||||
}
|
||||
|
||||
currentCharacterModel = newCharacterModel;
|
||||
|
||||
@@ -451,9 +591,7 @@ public class buildPlayer : MonoBehaviour
|
||||
|
||||
newModelAnimator.enabled = false;
|
||||
|
||||
// DestroyImmediate (newModelAnimator);
|
||||
|
||||
if (isInstantiated) {
|
||||
if (isInstantiated && !replacingCharacterModelInRuntimeActive) {
|
||||
placeCharacterInCameraPosition ();
|
||||
}
|
||||
|
||||
@@ -477,16 +615,20 @@ public class buildPlayer : MonoBehaviour
|
||||
|
||||
newCharacterModel = null;
|
||||
|
||||
eventOnCreatePlayer.Invoke ();
|
||||
if (!replacingCharacterModelInRuntimeActive) {
|
||||
eventOnCreatePlayer.Invoke ();
|
||||
}
|
||||
|
||||
if (currentCharacterModel != null) {
|
||||
eventToSendNewPlayerModel.Invoke (currentCharacterModel);
|
||||
}
|
||||
|
||||
updateComponent ();
|
||||
if (!replacingCharacterModelInRuntimeActive || !applicationisPlaying) {
|
||||
updateComponent ();
|
||||
|
||||
print ("IMPORTANT: Character created successfully. Remember to check the component Upper Body Rotation System, in Player Controller gameObject. In that inspector, check the value " +
|
||||
"Chest Up Vector and adjust it if the player spine behaves strange when aiming a weapon in third person. You can find a better explanation in the documentation");
|
||||
print ("IMPORTANT: Character created successfully. Remember to check the component Upper Body Rotation System, in Player Controller gameObject. In that inspector, check the value " +
|
||||
"Chest Up Vector and adjust it if the player spine behaves strange when aiming a weapon in third person. You can find a better explanation in the documentation");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -539,6 +681,12 @@ public class buildPlayer : MonoBehaviour
|
||||
if (ragdollActivatorManager != null) {
|
||||
ragdollActivatorManager.setCharacterBody (newCharacterModel, newModelAnimator);
|
||||
}
|
||||
|
||||
if (replacingCharacterModelInRuntimeActive) {
|
||||
ragdollBuilderManager.setRagdollCollidersState (false);
|
||||
|
||||
ragdollActivatorManager.enableOrDisableRagdollPhysics (false);
|
||||
}
|
||||
}
|
||||
|
||||
void setIKFootElements ()
|
||||
@@ -556,6 +704,8 @@ public class buildPlayer : MonoBehaviour
|
||||
return;
|
||||
}
|
||||
|
||||
updateApplicationisPlayingValue ();
|
||||
|
||||
checkUnpackCharacterPrefab ();
|
||||
|
||||
currentPlayerComponentsManager = player.GetComponent<playerComponentsManager> ();
|
||||
@@ -577,6 +727,13 @@ public class buildPlayer : MonoBehaviour
|
||||
updateComponent ();
|
||||
}
|
||||
|
||||
public void setCustomChestUpVectorValue (Vector3 newValue)
|
||||
{
|
||||
newChestUpVectorValue = newValue;
|
||||
|
||||
setNewChestUpVectorValueActive = (newChestUpVectorValue != -Vector3.one);
|
||||
}
|
||||
|
||||
void setIKUpperBodyComponents ()
|
||||
{
|
||||
upperBodyRotationManager.setSpineTransform (spine);
|
||||
@@ -586,19 +743,33 @@ public class buildPlayer : MonoBehaviour
|
||||
|
||||
localDirection = new Vector3 (Mathf.RoundToInt (localDirection.x), Mathf.RoundToInt (localDirection.y), Mathf.RoundToInt (localDirection.z));
|
||||
|
||||
if (setNewChestUpVectorValueActive) {
|
||||
localDirection = newChestUpVectorValue;
|
||||
|
||||
setNewChestUpVectorValueActive = false;
|
||||
}
|
||||
|
||||
upperBodyRotationManager.setNewChestUpVectorValue (localDirection);
|
||||
|
||||
Transform currentMountPointChest = mainBodyMountPointsSystem.getHumanBoneMountPointTransformByName (mainChestMountPointName);
|
||||
|
||||
if (currentMountPointChest != null) {
|
||||
print ("Chest bones names " + currentMountPointChest.name + " " + chest.name);
|
||||
if (!applicationisPlaying) {
|
||||
print ("Chest bones names " + currentMountPointChest.name + " " + chest.name);
|
||||
}
|
||||
|
||||
if (currentMountPointChest != chest) {
|
||||
mainBodyMountPointsSystem.setCustomBoneMountPointTransformByName (mainChestMountPointName, chest, true);
|
||||
|
||||
mainBodyMountPointsSystem.setIndividualCharacterBodyMountPointInfoByName (mainChestMountPointName);
|
||||
|
||||
print ("New Chest Bone assigned on mount point system\n\n");
|
||||
if (!applicationisPlaying) {
|
||||
print ("New Chest Bone assigned on mount point system\n\n");
|
||||
}
|
||||
} else {
|
||||
if (!applicationisPlaying) {
|
||||
print ("Chest bone hasn't changed on mount point, all is properly update");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -609,6 +780,7 @@ public class buildPlayer : MonoBehaviour
|
||||
mapSystemManager.searchBuildingList ();
|
||||
}
|
||||
}
|
||||
|
||||
void setHealthWeakSpots ()
|
||||
{
|
||||
if (!buildPlayerType) {
|
||||
@@ -637,10 +809,12 @@ public class buildPlayer : MonoBehaviour
|
||||
weaponsManager.setLeftHandTransform (leftHand);
|
||||
}
|
||||
|
||||
weaponsManager.setWeaponList ();
|
||||
if (!replacingCharacterModelInRuntimeActive) {
|
||||
weaponsManager.setWeaponList ();
|
||||
|
||||
if (!hasWeaponsEnabled) {
|
||||
weaponsManager.enableOrDisableWeaponsList (false);
|
||||
if (!hasWeaponsEnabled) {
|
||||
weaponsManager.enableOrDisableWeaponsList (false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -674,9 +848,7 @@ public class buildPlayer : MonoBehaviour
|
||||
playerCullingSystem currentPlayerCullingSystem = playerCameraGameObject.GetComponent<playerCullingSystem> ();
|
||||
|
||||
if (currentPlayerCullingSystem != null && currentSkinnedMeshRenderer != null) {
|
||||
currentPlayerCullingSystem.playerGameObjectList.Clear ();
|
||||
|
||||
currentPlayerCullingSystem.playerGameObjectList.Add (currentSkinnedMeshRenderer.gameObject);
|
||||
currentPlayerCullingSystem.setNewPlayerGameObject (currentSkinnedMeshRenderer.gameObject);
|
||||
|
||||
currentPlayerCullingSystem.storePlayerRendererFromEditor ();
|
||||
}
|
||||
@@ -690,11 +862,16 @@ public class buildPlayer : MonoBehaviour
|
||||
characterCustomizationManager currentCharacterCustomizationManager = GetComponentInChildren<characterCustomizationManager> ();
|
||||
|
||||
if (currentCharacterCustomizationManager != null) {
|
||||
currentInventoryCharacterCustomizationSystem.mainCharacterCustomizationManager = currentCharacterCustomizationManager;
|
||||
currentInventoryCharacterCustomizationSystem.setNewCharacterCustomizationManager (currentCharacterCustomizationManager);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public GameObject getPlayerGameObject ()
|
||||
{
|
||||
return player;
|
||||
}
|
||||
|
||||
public void setCharacterValuesAndAdjustSettingsExternally (bool characterHasBeenPreInstantiatedOnEditorValue,
|
||||
bool characterIsAI,
|
||||
bool configuredAsEnemy,
|
||||
|
||||
Reference in New Issue
Block a user