From 0e5b672e0a9ebfe312d14b031ca484052583ad17 Mon Sep 17 00:00:00 2001 From: Joshua Reason Date: Mon, 9 Sep 2019 10:28:14 +1000 Subject: [PATCH] worked on characters animation --- .../Plugins/IngameDebugConsole/Android.meta | 8 - .../Plugins/IngameDebugConsole/Prefabs.meta | 8 - .../Plugins/IngameDebugConsole/Scripts.meta | 8 - .../IngameDebugConsole/Sprites/Unused.meta | 8 - Assets/Scripts/Character.cs | 6 +- .../{Models.meta => Scripts/Components.meta} | 2 +- Assets/Scripts/LevelBlocks/Block.cs | 2 +- Assets/Scripts/Logic/Blocks/Jump.cs | 7 +- Assets/Scripts/Logic/Blocks/Move.cs | 10 +- Assets/Scripts/LogicBlocks.meta | 8 - .../Animals1_Mesh/Bear.fbx.meta | 174 +++++++++++++++++- 11 files changed, 191 insertions(+), 50 deletions(-) delete mode 100644 Assets/Plugins/IngameDebugConsole/Android.meta delete mode 100644 Assets/Plugins/IngameDebugConsole/Prefabs.meta delete mode 100644 Assets/Plugins/IngameDebugConsole/Scripts.meta delete mode 100644 Assets/Plugins/IngameDebugConsole/Sprites/Unused.meta rename Assets/{Models.meta => Scripts/Components.meta} (77%) delete mode 100644 Assets/Scripts/LogicBlocks.meta diff --git a/Assets/Plugins/IngameDebugConsole/Android.meta b/Assets/Plugins/IngameDebugConsole/Android.meta deleted file mode 100644 index 12049b6..0000000 --- a/Assets/Plugins/IngameDebugConsole/Android.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 3d7d7a61a5341904eb3c65af025b1d86 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/IngameDebugConsole/Prefabs.meta b/Assets/Plugins/IngameDebugConsole/Prefabs.meta deleted file mode 100644 index 6aa8bf2..0000000 --- a/Assets/Plugins/IngameDebugConsole/Prefabs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 7dbc36665bc0d684db9a4447e27a7a4b -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/IngameDebugConsole/Scripts.meta b/Assets/Plugins/IngameDebugConsole/Scripts.meta deleted file mode 100644 index 72dcaac..0000000 --- a/Assets/Plugins/IngameDebugConsole/Scripts.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 860c08388401a6d4e858fe4910ea9337 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/IngameDebugConsole/Sprites/Unused.meta b/Assets/Plugins/IngameDebugConsole/Sprites/Unused.meta deleted file mode 100644 index f3769b1..0000000 --- a/Assets/Plugins/IngameDebugConsole/Sprites/Unused.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: f6caae32d463529478f2186f47c2e3fe -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/Character.cs b/Assets/Scripts/Character.cs index 7ae160d..65beb0b 100644 --- a/Assets/Scripts/Character.cs +++ b/Assets/Scripts/Character.cs @@ -129,6 +129,8 @@ public class Character : MonoBehaviour } yield return StartCoroutine(LerpToBlock(target, time, yFunction)); + + _currentBlock= target; switch (animation) { @@ -158,7 +160,9 @@ public class Character : MonoBehaviour { _newPos = Vector3.Lerp(_startPos, _endPos, (elapsedTime / time)); - _newPos.y += heightOffset(elapsedTime / time); + + if (heightOffset != null) + _newPos.y += heightOffset(elapsedTime / time); transform.position = _newPos; diff --git a/Assets/Models.meta b/Assets/Scripts/Components.meta similarity index 77% rename from Assets/Models.meta rename to Assets/Scripts/Components.meta index 5346456..5a95b09 100644 --- a/Assets/Models.meta +++ b/Assets/Scripts/Components.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 296bd90e667df1f4697823a0aa45acf0 +guid: 8d7394d70ec233849a60a26da5f23b75 folderAsset: yes DefaultImporter: externalObjects: {} diff --git a/Assets/Scripts/LevelBlocks/Block.cs b/Assets/Scripts/LevelBlocks/Block.cs index 36b8025..946b254 100644 --- a/Assets/Scripts/LevelBlocks/Block.cs +++ b/Assets/Scripts/LevelBlocks/Block.cs @@ -113,7 +113,7 @@ public class Block : MonoBehaviour Block[] blocks = cols.Where(p => p.GetComponent() != null).Select(p => p.GetComponent()).ToArray(); //Draw cube, for visuals - //DebugExtensions.DrawCube(position, halfExtent, Color.cyan, 1, false); + DebugExtensions.DrawCube(position, halfExtent, Color.cyan, 1, false); //if didn't hit anyblocks return false if (blocks.Length == 0) diff --git a/Assets/Scripts/Logic/Blocks/Jump.cs b/Assets/Scripts/Logic/Blocks/Jump.cs index b0f69bb..6e0dcf8 100644 --- a/Assets/Scripts/Logic/Blocks/Jump.cs +++ b/Assets/Scripts/Logic/Blocks/Jump.cs @@ -30,7 +30,12 @@ public class Jump : LogicBlock /// Player to move protected override void BlockLogic(Character player, float animationTime) { - player.Jump(direction, animationTime); + //player.Jump(direction, animationTime); + + player.justMoved = true; + Block endBlock = GetEndBlock(player.CurrentBlock, player.transform, ~player.Ignore); + player.StartCoroutine(player.MoveToBlock(endBlock, Character.Animation.Jump, animationTime)); + } /// diff --git a/Assets/Scripts/Logic/Blocks/Move.cs b/Assets/Scripts/Logic/Blocks/Move.cs index 89825a9..ded9178 100644 --- a/Assets/Scripts/Logic/Blocks/Move.cs +++ b/Assets/Scripts/Logic/Blocks/Move.cs @@ -23,8 +23,11 @@ public class Move : LogicBlock { player.justMoved = true; //player.Move(direction, animationTime); - Block endBlock = GetEndBlock(player.CurrentBlock, player.transform, player.Ignore); - player.MoveToBlock(endBlock, Character.Animation.Walk, animationTime); + Block endBlock = GetEndBlock(player.CurrentBlock, player.transform, ~player.Ignore); + + Debug.Log("CurrentBlock: " + player.CurrentBlock.position + "\nEndBlock: " + endBlock.position); + + player.StartCoroutine(player.MoveToBlock(endBlock, Character.Animation.Walk, animationTime)); } /// @@ -35,6 +38,9 @@ public class Move : LogicBlock /// public override Block GetEndBlock(Block startBlock,Transform tranform, LayerMask layerMask) { + + DebugExtensions.DrawCube(startBlock.position, Vector3.one / 2, Color.red, 3, false); + Vector3 wantedPosition = startBlock.position + direction.ToVector(tranform); // position wanted Block hit; //output of block detection Block retVal = startBlock; //Block we'll move to diff --git a/Assets/Scripts/LogicBlocks.meta b/Assets/Scripts/LogicBlocks.meta deleted file mode 100644 index 98af9d1..0000000 --- a/Assets/Scripts/LogicBlocks.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 8936b441d7647f74884c94f97bfb8931 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Third Party Assets/KUBIKOS - Cube Mini Animals/Animals1_Mesh/Bear.fbx.meta b/Assets/Third Party Assets/KUBIKOS - Cube Mini Animals/Animals1_Mesh/Bear.fbx.meta index 70f5cf3..92c4bda 100644 --- a/Assets/Third Party Assets/KUBIKOS - Cube Mini Animals/Animals1_Mesh/Bear.fbx.meta +++ b/Assets/Third Party Assets/KUBIKOS - Cube Mini Animals/Animals1_Mesh/Bear.fbx.meta @@ -1,9 +1,7 @@ fileFormatVersion: 2 guid: ecb900ca4b414eae9053afe2b45f3656 -timeCreated: 1505749502 -licenseType: Store ModelImporter: - serializedVersion: 19 + serializedVersion: 23 fileIDToRecycleName: 100000: //RootNode 100002: Bear @@ -34,12 +32,22 @@ ModelImporter: 7400010: Attack 7400012: Hit 7400014: JumpInplace + 7400016: Sit + 7400018: Stand + 7400020: SitIdle 9500000: //RootNode 13700000: Bear + externalObjects: + - first: + type: UnityEngine:Material + assembly: UnityEngine.CoreModule + name: Material_CubeAnimals_SHDR + second: {fileID: 2100000, guid: 6e494e65902c4d058104285116e11f82, type: 2} materials: importMaterials: 1 materialName: 0 materialSearch: 1 + materialLocation: 0 animations: legacyGenerateAnimations: 4 bakeSimulation: 0 @@ -52,12 +60,15 @@ ModelImporter: animationImportWarnings: animationRetargetingWarnings: animationDoRetargetingWarnings: 0 + importAnimatedCustomProperties: 0 + importConstraints: 0 animationCompression: 1 animationRotationError: 0.5 animationPositionError: 0.5 animationScaleError: 0.5 animationWrapMode: 0 extraExposedTransformPaths: [] + extraUserProperties: [] clipAnimations: - serializedVersion: 16 name: Idle @@ -443,28 +454,184 @@ ModelImporter: maskType: 3 maskSource: {instanceID: 0} additiveReferencePoseFrame: 0 + - serializedVersion: 16 + name: Sit + takeName: Take 001 + firstFrame: 40 + lastFrame: 60 + wrapMode: 0 + orientationOffsetY: 0 + level: 0 + cycleOffset: 0 + loop: 0 + hasAdditiveReferencePose: 0 + loopTime: 0 + loopBlend: 0 + loopBlendOrientation: 0 + loopBlendPositionY: 0 + loopBlendPositionXZ: 0 + keepOriginalOrientation: 0 + keepOriginalPositionY: 1 + keepOriginalPositionXZ: 0 + heightFromFeet: 0 + mirror: 0 + bodyMask: 01000000010000000100000001000000010000000100000001000000010000000100000001000000010000000100000001000000 + curves: [] + events: [] + transformMask: + - path: + weight: 1 + - path: Bear + weight: 1 + - path: Bear_Root + weight: 1 + - path: Bear_Root/Body + weight: 1 + - path: Bear_Root/Body/Eye_L + weight: 1 + - path: Bear_Root/Body/Eye_R + weight: 1 + - path: Bear_Root/Body/LegBack_L + weight: 1 + - path: Bear_Root/Body/LegBack_R + weight: 1 + - path: Bear_Root/Body/LegFront_L + weight: 1 + - path: Bear_Root/Body/LegFront_R + weight: 1 + maskType: 3 + maskSource: {instanceID: 0} + additiveReferencePoseFrame: 0 + - serializedVersion: 16 + name: Stand + takeName: Take 001 + firstFrame: 110 + lastFrame: 140 + wrapMode: 0 + orientationOffsetY: 0 + level: 0 + cycleOffset: 0 + loop: 0 + hasAdditiveReferencePose: 0 + loopTime: 0 + loopBlend: 0 + loopBlendOrientation: 0 + loopBlendPositionY: 0 + loopBlendPositionXZ: 0 + keepOriginalOrientation: 0 + keepOriginalPositionY: 1 + keepOriginalPositionXZ: 0 + heightFromFeet: 0 + mirror: 0 + bodyMask: 01000000010000000100000001000000010000000100000001000000010000000100000001000000010000000100000001000000 + curves: [] + events: [] + transformMask: + - path: + weight: 1 + - path: Bear + weight: 1 + - path: Bear_Root + weight: 1 + - path: Bear_Root/Body + weight: 1 + - path: Bear_Root/Body/Eye_L + weight: 1 + - path: Bear_Root/Body/Eye_R + weight: 1 + - path: Bear_Root/Body/LegBack_L + weight: 1 + - path: Bear_Root/Body/LegBack_R + weight: 1 + - path: Bear_Root/Body/LegFront_L + weight: 1 + - path: Bear_Root/Body/LegFront_R + weight: 1 + maskType: 3 + maskSource: {instanceID: 0} + additiveReferencePoseFrame: 0 + - serializedVersion: 16 + name: SitIdle + takeName: Take 001 + firstFrame: 60 + lastFrame: 110 + wrapMode: 0 + orientationOffsetY: 0 + level: 0 + cycleOffset: 0 + loop: 0 + hasAdditiveReferencePose: 0 + loopTime: 1 + loopBlend: 0 + loopBlendOrientation: 0 + loopBlendPositionY: 0 + loopBlendPositionXZ: 0 + keepOriginalOrientation: 0 + keepOriginalPositionY: 1 + keepOriginalPositionXZ: 0 + heightFromFeet: 0 + mirror: 0 + bodyMask: 01000000010000000100000001000000010000000100000001000000010000000100000001000000010000000100000001000000 + curves: [] + events: [] + transformMask: + - path: + weight: 1 + - path: Bear + weight: 1 + - path: Bear_Root + weight: 1 + - path: Bear_Root/Body + weight: 1 + - path: Bear_Root/Body/Eye_L + weight: 1 + - path: Bear_Root/Body/Eye_R + weight: 1 + - path: Bear_Root/Body/LegBack_L + weight: 1 + - path: Bear_Root/Body/LegBack_R + weight: 1 + - path: Bear_Root/Body/LegFront_L + weight: 1 + - path: Bear_Root/Body/LegFront_R + weight: 1 + maskType: 3 + maskSource: {instanceID: 0} + additiveReferencePoseFrame: 0 isReadable: 1 meshes: lODScreenPercentages: [] globalScale: 1 meshCompression: 0 addColliders: 0 + useSRGBMaterialColor: 1 + importVisibility: 0 importBlendShapes: 1 + importCameras: 0 + importLights: 0 swapUVChannels: 0 generateSecondaryUV: 0 useFileUnits: 1 optimizeMeshForGPU: 1 keepQuads: 0 weldVertices: 1 + preserveHierarchy: 0 + indexFormat: 1 secondaryUVAngleDistortion: 8 secondaryUVAreaDistortion: 15.000001 secondaryUVHardAngle: 88 secondaryUVPackMargin: 4 useFileScale: 1 + previousCalculatedGlobalScale: 0.01 + hasPreviousCalculatedGlobalScale: 1 tangentSpace: normalSmoothAngle: 60 normalImportMode: 0 tangentImportMode: 3 + normalCalculationMode: 0 + legacyComputeAllNormalsFromSmoothingGroupsWhenMeshHasBlendShapes: 1 + blendShapeNormalImportMode: 1 + normalSmoothingSource: 0 importAnimation: 1 copyAvatar: 0 humanDescription: @@ -479,7 +646,6 @@ ModelImporter: legStretch: 0.05 feetSpacing: 0 rootMotionBoneName: - rootMotionBoneRotation: {x: 0, y: 0, z: 0, w: 1} hasTranslationDoF: 0 hasExtraRoot: 0 skeletonHasParents: 1