Skip to content

Commit

Permalink
walking animation
Browse files Browse the repository at this point in the history
  • Loading branch information
leon-arndt committed Jan 3, 2023
1 parent 608d0d9 commit 57ec1aa
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 3 deletions.
53 changes: 50 additions & 3 deletions Assets/Prefabs/Character/Follower.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Transform:
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 1186171629575057601}
- {fileID: 2118372701120944476}
- {fileID: 5693083519800121498}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
Expand Down Expand Up @@ -207,12 +207,12 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3065583160552160243}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: -0.5, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 2555234802472079653}
m_Father: {fileID: 5693083519800121498}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!212 &8347242678371508119
Expand Down Expand Up @@ -279,6 +279,53 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 32c6a26b2a994044ab182fda4d83c6fe, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &5965601143882076925
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 5693083519800121498}
- component: {fileID: 5191608515953469750}
m_Layer: 0
m_Name: Visuals
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &5693083519800121498
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5965601143882076925}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 2118372701120944476}
m_Father: {fileID: 2555234802472079653}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &5191608515953469750
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5965601143882076925}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e2ab4c2d9413455c93d6366e7675e95f, type: 3}
m_Name:
m_EditorClassIdentifier:
moveHeight: 0.1
rotateAmount: 15
--- !u!1001 &1728425348964210474
PrefabInstance:
m_ObjectHideFlags: 0
Expand Down
29 changes: 29 additions & 0 deletions Assets/Scripts/Utility/Walk.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using DG.Tweening;
using UnityEngine;

namespace Utility
{
public class Walk : MonoBehaviour
{
[SerializeField] private float moveHeight = 0.1f;
[SerializeField] private float rotateAmount = 15f;

private Tween bounceTween, rotateTween;

private void Start()
{
const float bounceDuration = 0.15f;
bounceTween = transform
.DOLocalMoveY(moveHeight, bounceDuration)
.SetLoops(-1, LoopType.Yoyo)
.SetDelay(Random.value);

transform.Rotate(Vector3.forward * -0.5f * rotateAmount, Space.Self);
rotateTween = transform
.DOLocalRotate(Vector3.forward * rotateAmount, 1f)
.SetLoops(-1, LoopType.Yoyo)
.SetDelay(Random.value)
.SetEase(Ease.InOutSine);
}
}
}
3 changes: 3 additions & 0 deletions Assets/Scripts/Utility/Walk.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 57ec1aa

Please sign in to comment.