public static RuntimeAnimatorController Create(SmwCharacterGenerics smwCharacterGenerics, SmwCharacter smwCharacter, Teams teamId) { string charName = smwCharacter.charName; if (charName == "") { Debug.LogError("smwCharacter hat keinen namen gesetzt!"); charName = "unnamedChar"; } Debug.Log("CharacterAnimator" + " Create () " + charName); string createdCharacterFolderPath = "Animations/Characters/AutoGenerated/" + charName + "_" + teamId; if (!AssetTools.TryCreateFolderWithAssetDatabase(createdCharacterFolderPath, out createdCharacterFolderPath)) { Debug.LogError("Ordner existiert/existerieren nicht und kann/können nicht angelegt werden!\n" + createdCharacterFolderPath); return(null); } /** * AssetDatabase : All paths are relative to the project folder => paths always = "Assets/..../..." //TODO last folder no SLASH / !!! **/ // string assetCreatedCharacterFolderPath = "Assets/" + createdCharacterFolderPath; AnimatorController controller = AnimatorController.CreateAnimatorControllerAtPath(createdCharacterFolderPath + "/" + charName + "_" + teamId + "_scripted_AnimatorController.controller"); AddAnimatorControllerParameter(controller); #region Layer 0 State Machine // Layer 0 State Machine AnimatorStateMachine rootStateMachine = controller.layers[0].stateMachine; Vector3 anyStatePos = rootStateMachine.anyStatePosition; //Vector3 entryStatePos = rootStateMachine.entryPosition; Vector3 refStatePos = anyStatePos; Vector3 tempStatePos; tempStatePos = anyStatePos; tempStatePos.x += 200; rootStateMachine.anyStatePosition = tempStatePos; /* Add states */ tempStatePos.x = refStatePos.x + 200; tempStatePos.y = refStatePos.y - 200; AnimatorState idleState = rootStateMachine.AddState(HashID.s_Idle, tempStatePos); // idleState.motion = idleAnim; tempStatePos.x = refStatePos.x + 200; tempStatePos.y = refStatePos.y - 100; AnimatorState jumpState = rootStateMachine.AddState(HashID.s_JumpAndFall, tempStatePos); // jumpState.motion = jumpAnim; tempStatePos.x = refStatePos.x + 200; tempStatePos.y = refStatePos.y - 300; AnimatorState runState = rootStateMachine.AddState(HashID.s_Run, tempStatePos); // runState.motion = runAnim; tempStatePos.x = refStatePos.x + 200; tempStatePos.y = refStatePos.y - 400; AnimatorState skidState = rootStateMachine.AddState(HashID.s_ChangeRunDirection, tempStatePos); // skidState.motion = changeRunDirectionAnim; tempStatePos.x = refStatePos.x + 600; tempStatePos.y = refStatePos.y; AnimatorState hittedState = rootStateMachine.AddState(HashID.s_Generic_Hitted, tempStatePos); // hittedState.motion = idleAnim; tempStatePos.x = refStatePos.x + 750; tempStatePos.y = refStatePos.y - 100; AnimatorState headJumpedState = rootStateMachine.AddState(HashID.s_HeadJumped, tempStatePos); // headJumpedState.motion = headJumpedAnim; tempStatePos.x = refStatePos.x + 450; tempStatePos.y = refStatePos.y - 100; AnimatorState gameOverState = rootStateMachine.AddState(HashID.s_GameOver, tempStatePos); // gameOverState.motion = headJumpedAnim; tempStatePos.x = refStatePos.x + 600; tempStatePos.y = refStatePos.y - 200; AnimatorState deadState = rootStateMachine.AddState(HashID.s_Dead, tempStatePos); // deadState.motion = headJumpedAnim; tempStatePos.x = refStatePos.x + 750; tempStatePos.y = refStatePos.y - 300; AnimatorState spawnState = rootStateMachine.AddState(HashID.s_Generic_Spawn, tempStatePos); spawnState.AddStateMachineBehaviour(typeof(SpawnStateScript)); //TODO reference zu characterScript direct mitgeben??? // spawnState.AddStateMachineBehaviour(new SpawnStateScript()); tempStatePos.x = refStatePos.x + 800; tempStatePos.y = refStatePos.y - 400; AnimatorState spawnDelayState = rootStateMachine.AddState(HashID.s_Generic_SpawnDelay, tempStatePos); spawnDelayState.AddStateMachineBehaviour(typeof(SpawnDelayStateScript)); //TODO reference zu characterScript direct mitgeben??? // spawnState.AddStateMachineBehaviour(new SpawnDelayStateScript()); // spawnState.motion = headJumpedAnim; // AnimatorState spawnProtectionState = rootStateMachine.AddState(HashID.s_Generic_SpawnProtection); // spawnProtectionState.motion = headJumpedAnim; #endregion #region Layer 1 State Machine - Overlay Layer /** * Layer 1 - Overlay Layer **/ // FIX defaultWeight and blendingMode!!!! // // Manual Creating Layer : http://forum.unity3d.com/threads/animatorcontroller-addlayer-doesnt-create-default-animatorstatemachine.307873/#post-2003218 AnimatorControllerLayer newLayer = new AnimatorControllerLayer(); newLayer.name = HashID.l_overlay; newLayer.stateMachine = new AnimatorStateMachine(); newLayer.stateMachine.name = newLayer.name; newLayer.stateMachine.hideFlags = HideFlags.HideInHierarchy; if (AssetDatabase.GetAssetPath(controller) != "") { AssetDatabase.AddObjectToAsset(newLayer.stateMachine, AssetDatabase.GetAssetPath(controller)); } //Custom newLayer.blendingMode = AnimatorLayerBlendingMode.Override; newLayer.defaultWeight = 1f; controller.AddLayer(newLayer); // Another Way: //Animator anim; //anim.SetLayerWeight (layerIndex, weight) // // Auto Creating Layer & StateMachine AddLayer(string)!!! // controller.AddLayer(HashID.l_overlay); // controller.layers[1].blendingMode = AnimatorLayerBlendingMode.Additive; // setzt für die zeit die es aktiv ist die variablen und wenn deaktiviert wird variable auf vorherigen wert gesetzt // controller.layers[1].defaultWeight = 1f; if (controller.layers[1].stateMachine == null) { Debug.LogError("stateMachine == null"); // controller.layers[1].stateMachine = new AnimatorStateMachine(); } // Layer 1 State Machine // controller.layers[1].blendingMode = AnimatorLayerBlendingMode.Override; // setzt für die zeit die es aktiv ist die variablen und wenn deaktiviert wird variable auf vorherigen wert gesetzt // controller.layers[1].defaultWeight = 1f; AnimatorStateMachine overlayStateMachine = controller.layers[1].stateMachine; refStatePos = overlayStateMachine.anyStatePosition; tempStatePos.x = refStatePos.x + 200; tempStatePos.y = refStatePos.y; AnimatorState defaultOverlayState = overlayStateMachine.AddState(HashID.s_l1_Generic_DefaultState, tempStatePos); tempStatePos.x = refStatePos.x + 200; tempStatePos.y = refStatePos.y - 100; AnimatorState invincibleOverlayState = overlayStateMachine.AddState(HashID.s_l1_Generic_Invincible, tempStatePos); tempStatePos.x = refStatePos.x + 200; tempStatePos.y = refStatePos.y + 100; AnimatorState protectionOverlayState = overlayStateMachine.AddState(HashID.s_l1_Generic_Protection, tempStatePos); #endregion #region Layer 1 State Machine - Overlay Layer Transitions AnimatorStateTransition leaveInvincibleEnterDefaultState = invincibleOverlayState.AddTransition(defaultOverlayState); // leaveInvincibleEnterDefaultState.AddCondition(AnimatorConditionMode.If, 0, HashID.p_rageTrigger); SetupAnimatorStateTransition(leaveInvincibleEnterDefaultState, 0f, true, 1f, false); AnimatorStateTransition leaveProtectionEnterDefaultStateByTime = protectionOverlayState.AddTransition(defaultOverlayState); // leaveInvincibleEnterDefaultState.AddCondition(AnimatorConditionMode.If, 0, HashID.p_rageTrigger); SetupAnimatorStateTransition(leaveProtectionEnterDefaultStateByTime, 0f, true, 1f, false); AnimatorStateTransition leaveProtectionEnterDefaultStateByTrigger = protectionOverlayState.AddTransition(defaultOverlayState); SetupAnimatorStateTransition(leaveProtectionEnterDefaultStateByTrigger, 0f, false, 1f, false); leaveProtectionEnterDefaultStateByTrigger.AddCondition(AnimatorConditionMode.If, 0, HashID.p_stopProtectionTrigger); //TODO defaultOverlayState muss kräfte invincible/spawnprotection entfernen?? // Overlay Layer : AnyState Transitions to InvincibleState AnimatorStateTransition enterInvincibleOverlayerState = overlayStateMachine.AddAnyStateTransition(invincibleOverlayState); SetupAnimatorStateTransition(enterInvincibleOverlayerState, 0f, false, 1f, false); enterInvincibleOverlayerState.AddCondition(AnimatorConditionMode.If, 0, HashID.p_rageTrigger); // Overlay Layer : AnyState Transitions to ProtectionState AnimatorStateTransition enterProtectionOverlayerState = overlayStateMachine.AddAnyStateTransition(protectionOverlayState); //TODO rename SpawnProtection to Protection SetupAnimatorStateTransition(enterProtectionOverlayerState, 0f, false, 1f, false); enterProtectionOverlayerState.AddCondition(AnimatorConditionMode.If, 0, HashID.p_startProtectionTrigger); #endregion #region Layer 0 State Machine Transitions // Layer 0 - Base Layer float minHorizontalSpeed = 0.01f; // setze schwellwert (treshold) AnimatorStateTransition leaveIdleEnterRunIfGreater = idleState.AddTransition(runState); SetupAnimatorStateTransition(leaveIdleEnterRunIfGreater, 0f, false, 1f, false); leaveIdleEnterRunIfGreater.AddCondition(AnimatorConditionMode.Greater, minHorizontalSpeed, HashID.p_hSpeed); AnimatorStateTransition leaveIdleEnterRunIfLower = idleState.AddTransition(runState); SetupAnimatorStateTransition(leaveIdleEnterRunIfLower, 0f, false, 1f, false); leaveIdleEnterRunIfLower.AddCondition(AnimatorConditionMode.Less, -minHorizontalSpeed, HashID.p_hSpeed); AnimatorStateTransition leaveRunEnterIdle = runState.AddTransition(idleState); leaveRunEnterIdle.AddCondition(AnimatorConditionMode.Greater, -minHorizontalSpeed, HashID.p_hSpeed); leaveRunEnterIdle.AddCondition(AnimatorConditionMode.Less, minHorizontalSpeed, HashID.p_hSpeed); SetupAnimatorStateTransition(leaveRunEnterIdle, 0f, false, 1f, false); AnimatorStateTransition leaveRunEnterJump = runState.AddTransition(jumpState); leaveRunEnterJump.AddCondition(AnimatorConditionMode.IfNot, 0, HashID.p_grounded); SetupAnimatorStateTransition(leaveRunEnterJump, 0f, false, 1f, false); AnimatorStateTransition leaveIdleEnterJump = idleState.AddTransition(jumpState); SetupAnimatorStateTransition(leaveIdleEnterJump, 0f, false, 1f, false); leaveIdleEnterJump.AddCondition(AnimatorConditionMode.IfNot, 0, HashID.p_grounded); AnimatorStateTransition leaveJumpEnterIdle = jumpState.AddTransition(idleState); SetupAnimatorStateTransition(leaveJumpEnterIdle, 0f, false, 1f, false); leaveJumpEnterIdle.AddCondition(AnimatorConditionMode.If, 0, HashID.p_grounded); AnimatorStateTransition leaveRunEnterSkid = runState.AddTransition(skidState); SetupAnimatorStateTransition(leaveRunEnterSkid, 0f, false, 1f, false); leaveRunEnterSkid.AddCondition(AnimatorConditionMode.If, 0, HashID.p_changeRunDirectionTrigger); AnimatorStateTransition leaveSkidEnterRun = skidState.AddTransition(runState); SetupAnimatorStateTransition(leaveSkidEnterRun, 0f, true, 1f, false); //TODO achtung byTime! //leaveSkidEnterRun.AddCondition(AnimatorConditionMode.IfNot, 0, HashID.p_changeRunDirectionTrigger); // Any State Transistion AnimatorStateTransition fallingTransition = rootStateMachine.AddAnyStateTransition(jumpState); //special TODO markt SetupAnimatorStateTransition(fallingTransition, 0f, false, 1f, false); fallingTransition.AddCondition(AnimatorConditionMode.IfNot, 0, HashID.p_grounded); // Any State Transistion AnimatorStateTransition hittedTransition = rootStateMachine.AddAnyStateTransition(hittedState); //special TODO markt SetupAnimatorStateTransition(hittedTransition, 0f, false, 1f, false); hittedTransition.AddCondition(AnimatorConditionMode.If, 0, HashID.p_hitTrigger); AnimatorStateTransition leaveHittedEnterHeadJumped = hittedState.AddTransition(headJumpedState); SetupAnimatorStateTransition(leaveHittedEnterHeadJumped, 0f, false, 1f, false); leaveHittedEnterHeadJumped.AddCondition(AnimatorConditionMode.If, 0, HashID.p_headJumped); // TODO <-- change to Trigger? p_headJumpedTrigger AnimatorStateTransition leaveHittedEnterDie = hittedState.AddTransition(deadState); SetupAnimatorStateTransition(leaveHittedEnterDie, 0f, false, 1f, false); leaveHittedEnterDie.AddCondition(AnimatorConditionMode.If, 0, HashID.p_dead); // TODO <-- change to name p_dieTrigger AnimatorStateTransition leaveHittedEnterGameOver = hittedState.AddTransition(gameOverState); SetupAnimatorStateTransition(leaveHittedEnterGameOver, 0f, false, 1f, false); leaveHittedEnterGameOver.AddCondition(AnimatorConditionMode.If, 0, HashID.p_gameOver); // TODO <-- change to name p_gameOverTrigger AnimatorStateTransition leaveHeadJumpedEnterSpawn = headJumpedState.AddTransition(spawnState); SetupAnimatorStateTransition(leaveHeadJumpedEnterSpawn, 0f, false, 1f, false); leaveHeadJumpedEnterSpawn.AddCondition(AnimatorConditionMode.If, 0, HashID.p_spawn); // TODO <-- change to name p_spawnTrigger AnimatorStateTransition leaveDieEnterSpawn = deadState.AddTransition(spawnState); SetupAnimatorStateTransition(leaveDieEnterSpawn, 0f, false, 1f, false); leaveDieEnterSpawn.AddCondition(AnimatorConditionMode.If, 0, HashID.p_spawn); // TODO <-- change to name p_spawnTrigger AnimatorStateTransition leaveSpawnEnterIdle = spawnState.AddTransition(idleState); SetupAnimatorStateTransition(leaveSpawnEnterIdle, 0f, true, 1f, false); //TODO achtung byTime! //TODO <-- Achtung hasExitTime (nach Animation) //leaveSpawnEnterIdle.AddCondition(AnimatorConditionMode.If, 0, HashID.p_spawn); //TODO add condition to enable controlls & enable gravity & & ... #endregion // init smwAnimations array // int baseLayerStateCount = 0; smwAnimations.Clear(); // BUG FIX! smwAnimations.Add(new SMWAnimation(charName + "_" + teamId + "_dynamic_Idle", 24, 1, smwCharacter.GetSprites(teamId, SmwCharacterAnimation.Idle), WrapMode.Loop, idleState)); smwAnimations.Add(new SMWAnimation(charName + "_" + teamId + "_dynamic_Run", 24, 2, smwCharacter.GetSprites(teamId, SmwCharacterAnimation.Run), WrapMode.Loop, runState)); smwAnimations.Add(new SMWAnimation(charName + "_" + teamId + "_dynamic_Jump", 24, 1, smwCharacter.GetSprites(teamId, SmwCharacterAnimation.Jump), WrapMode.Loop, jumpState)); smwAnimations.Add(new SMWAnimation(charName + "_" + teamId + "_dynamic_Skid", 24, 1, smwCharacter.GetSprites(teamId, SmwCharacterAnimation.Skid), WrapMode.Loop, skidState)); smwAnimations.Add(new SMWAnimation(charName + "_" + teamId + "_dynamic_Die", 24, 1, smwCharacter.GetSprites(teamId, SmwCharacterAnimation.Die), WrapMode.Loop, deadState)); smwAnimations.Add(new SMWAnimation(charName + "_" + teamId + "_dynamic_HeadJumped", 24, 1, smwCharacter.GetSprites(teamId, SmwCharacterAnimation.HeadJumped), WrapMode.Loop, headJumpedState)); GenerateAnimationClipAssets(smwAnimations, createdCharacterFolderPath, true); //TODO:: add Generic AnimationClips to characterAnimatorController spawnState.motion = smwCharacterGenerics.spawnAnimClip; protectionOverlayState.motion = smwCharacterGenerics.protectionAnimClip; invincibleOverlayState.motion = smwCharacterGenerics.rageAnimClip; //TODO //smwCharacter.runtimeAnimatorController = controller; smwCharacter.SetRuntimeAnimationController(teamId, controller); EditorUtility.SetDirty(smwCharacter); // save ScriptableObject return(controller); }
public void fillRootAndChildData(SmwCharacter characterSO, Teams teamId, SmwCharacterGenerics charGenerics) { float leftPos = -20f; // TODO inspector float rightPos = 20f; // TODO inspector float topPos = 15f; // TODO inspector float bottomPos = -15f; // TODO inspector Vector3 rootTransformPos = Vector3.zero; Vector3 centerTransformPos = rootTransformPos; Vector3 leftTransformPos = new Vector3(leftPos, 0f, 0f); Vector3 rightTransformPos = new Vector3(rightPos, 0f, 0f); Vector3 topTransformPos = new Vector3(0f, topPos, 0f); Vector3 bottomTransformPos = new Vector3(0f, bottomPos, 0f); Vector3 headTransformPos = new Vector3(0f, 0.3f, 0f); Vector3 feetTransformPos = new Vector3(0f, -0.3f, 0f); Vector3 bodyTransformPos = new Vector3(0f, 0f, 0f); //Vector3 itemCollectorTransformPos = new Vector3(0f,0f,0f); //Vector3 powerHitTransformPos = new Vector3(0f,0f,0f); Vector3 groundStopperTransformPos = new Vector3(0f, -0.25f, 0f); Vector3 kingTransformPos = new Vector3(0f, 0.6f, 0f); // Vector3 frictionEffectTransformPos = new Vector3(-0.42f, -0.42f, 0f); Vector2 headBoxSize = new Vector2(0.7f, 0.25f); //Vector2 feetBoxSize = new Vector2(0.7f,0.25f); Vector2 bodyBoxSize = new Vector2(0.7f, 0.8f); //Vector2 itemCollectorBoxSize = new Vector2(0.7f,0.8f); //Vector2 powerHitBoxSize = new Vector2(0.7f,0.8f); Vector2 groundStopperBoxSize = new Vector2(0.7f, 0.5f); Vector2 colliderOffSetCenter = Vector2.zero; Vector2 colliderOffSetLeft = new Vector2(leftPos, 0f); Vector2 colliderOffSetRight = new Vector2(rightPos, 0f); // Vector2 headBoxOffset; // use smartOffset // Vector2[] headBoxOffset = new Vector2[3]; // headBoxOffset [0] = colliderOffSetCenter; // headBoxOffset [1] = colliderOffSetLeft; // headBoxOffset [2] = colliderOffSetRight; Vector2[] smartComponentOffset = new Vector2[3]; smartComponentOffset[0] = colliderOffSetCenter; smartComponentOffset[1] = colliderOffSetLeft; smartComponentOffset[2] = colliderOffSetRight; bool headIsTrigger = true; //bool feetIsTrigger = true; bool bodyIsTrigger = false; //bool itemCollectorIsTrigger = true; //bool powerHitAreaIsTrigger = true; bool groundStopperIsTrigger = false; // root root = new ChildData(characterSO.charName, TagManager.Instance.tag_player, LayerManager.Instance.playerLayerName, centerTransformPos); //TODO Achtung PrefabName und Name können isch unterscheieden!!! root.Add(root.gameObject.AddComponent <SpriteRenderer>(), true, characterSO.GetSprites(teamId, SmwCharacterAnimation.Idle)[0], charGenerics.color_rootRenderer, charGenerics.rootRendererSortingLayer); Animator anim = root.Add(root.gameObject.AddComponent <Animator>(), true, characterSO.GetRuntimeAnimationController(teamId)); //TODO inspector // root.Add(root.gameObject.AddComponent<Rigidbody2D>(), 1f, true); //TODO inspector float gravityScale = 1f; float linearDrag = 3f; root.Add(root.gameObject.AddComponent <Rigidbody2D>(), gravityScale, RigidbodyConstraints2D.FreezeRotation, linearDrag); //TODO inspector root.Add(root.gameObject.AddComponent <AudioSource>(), true); //root.Add(root.gameObject.AddComponent<RealOwner>(), true); NetworkIdentity netIdScript = root.gameObject.AddComponent <NetworkIdentity> (); netIdScript.localPlayerAuthority = true; PlatformUserControl platformUserControl = root.gameObject.AddComponent <PlatformUserControl>(); PlatformCharacterScript platformCharScript = root.gameObject.AddComponent <PlatformCharacterScript>(); // build > 0.701 // add CharSO to CharPrefab platformCharScript.SetSmwCharacterSO(characterSO); root.Add(platformCharScript, true); root.Add(root.gameObject.AddComponent <PlatformJumperScript>(), false); // useUnityPhysics //root.Add(root.gameObject.AddComponent<Rage>(), true); //root.Add(root.gameObject.AddComponent<Shoot>(), true); //root.Add(root.gameObject.AddComponent<Shield>(), true); if (networked) { NetworkedPlayer netPlayerScript = root.gameObject.AddComponent <NetworkedPlayer> (); root.Add(netPlayerScript, true); netPlayerScript.AddBehaviour(platformCharScript); netPlayerScript.AddBehaviour(platformUserControl); NetworkAnimator netAnim = root.gameObject.AddComponent <NetworkAnimator> (); netAnim.animator = anim; NetworkTransform netTransform = root.gameObject.AddComponent <NetworkTransform> (); netTransform.transformSyncMode = NetworkTransform.TransformSyncMode.SyncRigidbody2D; netTransform.movementTheshold = (float)0.001f; netTransform.snapThreshold = 5f; float sendRate = 20.0f; // amount per seconds netTransform.sendInterval = 1.0f / sendRate; // time in seconds netTransform.syncRotationAxis = NetworkTransform.AxisSyncMode.None; //netTransform.syncRotationAxis = NetworkTransform.AxisSyncMode.AxisZ; netTransform.interpolateRotation = 1f; netTransform.rotationSyncCompression = NetworkTransform.CompressionSyncMode.High; } // root.Add(root.gameObject.AddComponent<NetworkView>(), true, netPlayerScript); //root.Add(root.gameObject.AddComponent<PushSkript>(), false); //root.Add(root.gameObject.AddComponent<Bot>(), false); // Clone Left ChildData child = new ChildData(TagManager.Instance.name_cloneLeft, TagManager.Instance.tag_player_clone, LayerManager.Instance.playerLayerName, leftTransformPos); child.Add(child.gameObject.AddComponent <SpriteRenderer>(), true, characterSO.GetSprites(teamId, SmwCharacterAnimation.Idle)[0], charGenerics.color_rootCloneRenderer, charGenerics.rootCloneRendererSortingLayer); child.Add(child.gameObject.AddComponent <CloneSpriteScript>(), true); childs.Add(child); // Clone Right child = new ChildData(TagManager.Instance.name_cloneRight, TagManager.Instance.tag_player_clone, LayerManager.Instance.playerLayerName, rightTransformPos); child.Add(child.gameObject.AddComponent <SpriteRenderer>(), true, characterSO.GetSprites(teamId, SmwCharacterAnimation.Idle)[0], charGenerics.color_rootCloneRenderer, charGenerics.rootCloneRendererSortingLayer); child.Add(child.gameObject.AddComponent <CloneSpriteScript>(), true); childs.Add(child); // Clone Top child = new ChildData(TagManager.Instance.name_CloneTop, TagManager.Instance.tag_player_clone, LayerManager.Instance.playerLayerName, topTransformPos); child.Add(child.gameObject.AddComponent <SpriteRenderer>(), true, characterSO.GetSprites(teamId, SmwCharacterAnimation.Idle)[0], charGenerics.color_rootCloneRenderer, charGenerics.rootCloneRendererSortingLayer); child.Add(child.gameObject.AddComponent <CloneSpriteScript>(), true); childs.Add(child); // Clone Bottom child = new ChildData(TagManager.Instance.name_CloneBottom, TagManager.Instance.tag_player_clone, LayerManager.Instance.playerLayerName, bottomTransformPos); child.Add(child.gameObject.AddComponent <SpriteRenderer>(), true, characterSO.GetSprites(teamId, SmwCharacterAnimation.Idle)[0], charGenerics.color_rootCloneRenderer, charGenerics.rootCloneRendererSortingLayer); child.Add(child.gameObject.AddComponent <CloneSpriteScript>(), true); childs.Add(child); // Head (cloned) child = new ChildData(TagManager.Instance.name_head, TagManager.Instance.tag_head, LayerManager.Instance.headLayerName, headTransformPos); child.Add(child.gameObject.AddComponent <BoxCollider2D>(), true, headBoxSize, smartComponentOffset, headIsTrigger, 3); childs.Add(child); //// Feet (cloned) child = new ChildData(TagManager.Instance.name_feet, TagManager.Instance.tag_player, LayerManager.Instance.feetLayerName, feetTransformPos); //child.Add(child.gameObject.AddComponent<BoxCollider2D>(), true, feetBoxSize, smartComponentOffset, feetIsTrigger, 3); //child.Add(child.gameObject.AddComponent<SendDamageTrigger>(),true); childs.Add(child); // Body (cloned) child = new ChildData(TagManager.Instance.name_body, TagManager.Instance.tag_body, LayerManager.Instance.bodyLayerName, bodyTransformPos); child.Add(child.gameObject.AddComponent <BoxCollider2D>(), true, bodyBoxSize, smartComponentOffset, bodyIsTrigger, 3); childs.Add(child); //// ItemCollector (cloned) //child = new ChildData (Tags.Instance.name_itemCollector, Tags.Instance.tag_itemCollector, Layer.Instance.itemLayerName, itemCollectorTransformPos); //child.Add(child.gameObject.AddComponent<BoxCollider2D>(), true, itemCollectorBoxSize, smartComponentOffset, itemCollectorIsTrigger, 3); //child.Add(child.gameObject.AddComponent<ItemCollectorScript>(),true); //childs.Add (child); //// PowerHitArea (cloned) //child = new ChildData (Tags.Instance.name_powerUpHitArea, Tags.Instance.tag_powerUpHitArea, Layer.Instance.powerUpLayerName, powerHitTransformPos); //child.Add(child.gameObject.AddComponent<BoxCollider2D>(), true, powerHitBoxSize, smartComponentOffset, powerHitAreaIsTrigger, 3); //child.Add(child.gameObject.AddComponent<RageTrigger>(),true); //childs.Add (child); // GroundStopper child = new ChildData(TagManager.Instance.name_groundStopper, TagManager.Instance.tag_groundStopper, LayerManager.Instance.groundStopperLayerName, groundStopperTransformPos); child.Add(child.gameObject.AddComponent <BoxCollider2D>(), true, groundStopperBoxSize, smartComponentOffset, groundStopperIsTrigger, 1); childs.Add(child); // King child = new ChildData(TagManager.Instance.name_king, TagManager.Instance.tag_body, LayerManager.Instance.defaultLayerName, kingTransformPos); child.Add(child.gameObject.AddComponent <SpriteRenderer>(), false, charGenerics.kingSprite, charGenerics.color_kingRenderer, charGenerics.kingRendererSortingLayer); childs.Add(child); // CurrentEstimatedPosOnServer child = new ChildData(TagManager.Instance.name_CurrentEstimatedPosOnServer, TagManager.Instance.tag_CurrentEstimatedPosOnServer, LayerManager.Instance.defaultLayerName, centerTransformPos); child.Add(child.gameObject.AddComponent <SpriteRenderer>(), true, characterSO.GetSprites(teamId, SmwCharacterAnimation.Idle)[0], charGenerics.color_currentEstimatedPosOnServer, charGenerics.currentEstimatedPosOnServerSortingLayer); childs.Add(child); // LastRecvedPos child = new ChildData(TagManager.Instance.name_lastReceivedPos, TagManager.Instance.tag_lastReceivedPos, LayerManager.Instance.defaultLayerName, centerTransformPos); child.Add(child.gameObject.AddComponent <SpriteRenderer>(), true, characterSO.GetSprites(teamId, SmwCharacterAnimation.Idle)[0], charGenerics.color_LastRecvedPos, charGenerics.lastRecvdPosRendererSortingLayer); childs.Add(child); // PredictedPosSimulatedWithLastInput child = new ChildData(TagManager.Instance.name_PredictedPosSimulatedWithLastInput, TagManager.Instance.tag_PredictedPosSimulatedWithLastInput, LayerManager.Instance.defaultLayerName, centerTransformPos); child.Add(child.gameObject.AddComponent <SpriteRenderer>(), true, characterSO.GetSprites(teamId, SmwCharacterAnimation.Idle)[0], charGenerics.color_PredictedPosSimulatedWithLastInput, charGenerics.preSimPosRendererSortingLayer); childs.Add(child); // PredictedPosCalculatedWithLastInput child = new ChildData(TagManager.Instance.name_PredictedPosCalculatedWithLastInput, TagManager.Instance.tag_PredictedPosCalculatedWithLastInput, LayerManager.Instance.defaultLayerName, centerTransformPos); child.Add(child.gameObject.AddComponent <SpriteRenderer>(), true, characterSO.GetSprites(teamId, SmwCharacterAnimation.Idle)[0], charGenerics.color_PredictedPosCalculatedWithLastInput, charGenerics.preCalclastRecvdPosRendererSortingLayer); childs.Add(child); // IceWalled child = new ChildData(TagManager.Instance.name_iceWalled, TagManager.Instance.tag_iceWalled, LayerManager.Instance.defaultLayerName, centerTransformPos); child.Add(child.gameObject.AddComponent <SpriteRenderer>(), true, null, charGenerics.color_iceWallRenderer, charGenerics.iceWalledRendererSortingLayer); child.Add(child.gameObject.AddComponent <Animator>(), true, charGenerics.iceWandAnimatorController); childs.Add(child); // Friction Effect with Prefav GameObject frictionEffectChildGO = GameObject.Instantiate(charGenerics.frictionSmokeTrailPrefab); frictionEffectChildGO.transform.SetParent(root.gameObject.transform); frictionEffectChildGO.name = TagManager.Instance.name_frictionEffect; platformCharScript.FrictionSmoke = frictionEffectChildGO.GetComponent <ParticleSystem> (); // Friction Effect manual creation // child = new ChildData (TagManager.Instance.name_frictionEffect, TagManager.Instance.tag_frictionEffect, LayerManager.Instance.defaultLayerName, frictionEffectTransformPos); // foreach (Component c in charGenerics.frictionSmokeTrailPrefab.GetComponents()) { // child.Add(child.gameObject.AddComponent(c)); // } }