Browse Source

Started working on more modular move

Josh_Dev_branch
SWIN\jreason 5 years ago
parent
commit
91bcfed8bd
3 changed files with 55 additions and 18 deletions
  1. +0
    -8
      Assets/Plugins/IngameDebugConsole.meta
  2. +55
    -2
      Assets/Scripts/Character.cs
  3. +0
    -8
      Assets/Scripts/Components.meta

+ 0
- 8
Assets/Plugins/IngameDebugConsole.meta View File

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

+ 55
- 2
Assets/Scripts/Character.cs View File

@ -7,7 +7,7 @@ using Networking.Server;
public class Character : MonoBehaviour
{
public enum Animation {Walk,Jump,Slide}
public enum Animation {Walk,Run,Jump,Slide}
public string nextScene;
Animator characterAnimator;
@ -106,7 +106,60 @@ public class Character : MonoBehaviour
return new Vector3(0, y, 0);
}
public IEnumerator MoveToBlock(Block Target, Animation animation, float time)
public IEnumerator MoveToBlock(Block target, Animation animation, float time)
{
switch (animation)
{
case Animation.Walk:
characterAnimator.SetBool("isWalking", true);
break;
case Animation.Run:
characterAnimator.SetBool("isRunning", true);
break;
case Animation.Jump:
characterAnimator.SetTrigger("Jump");
break;
default:
break;
}
yield return null;
}
public IEnumerator LerpToBlock(Block target,float time, System.Func<float,float> heightOffset)
{
Vector3 _startPos = transform.position;
Vector3 _endPos = target.VisualPosition;
Vector3 _newPos;
float elapsedTime = 0;
while(elapsedTime/time < 1)
{
_newPos = Vector3.Lerp(_startPos, _endPos, (elapsedTime / time));
_newPos.y += heightOffset(elapsedTime / time);
transform.position = _newPos;
yield return new WaitForEndOfFrame();
elapsedTime += Time.deltaTime;
}
_newPos = _endPos;
_newPos.y += heightOffset(elapsedTime / time);
transform.position = _newPos;
}
IEnumerator JumpCoroutine(Block Target, Transform Current, float time, float heightMax)
{

+ 0
- 8
Assets/Scripts/Components.meta View File

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

Loading…
Cancel
Save