Add accelerated movement and bobbing for crabs
This commit is contained in:
parent
e083092dff
commit
5764b28a4f
@ -32,7 +32,7 @@ AnimatorState:
|
|||||||
m_CorrespondingSourceObject: {fileID: 0}
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
m_PrefabInstance: {fileID: 0}
|
m_PrefabInstance: {fileID: 0}
|
||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_Name: CrabWalk
|
m_Name: Walk
|
||||||
m_Speed: 1
|
m_Speed: 1
|
||||||
m_CycleOffset: 0
|
m_CycleOffset: 0
|
||||||
m_Transitions: []
|
m_Transitions: []
|
||||||
@ -86,7 +86,7 @@ AnimatorState:
|
|||||||
m_CorrespondingSourceObject: {fileID: 0}
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
m_PrefabInstance: {fileID: 0}
|
m_PrefabInstance: {fileID: 0}
|
||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_Name: CrabAttack
|
m_Name: Attack
|
||||||
m_Speed: 1
|
m_Speed: 1
|
||||||
m_CycleOffset: 0
|
m_CycleOffset: 0
|
||||||
m_Transitions: []
|
m_Transitions: []
|
||||||
|
@ -22,6 +22,8 @@ GameObject:
|
|||||||
- component: {fileID: 592487110401094201}
|
- component: {fileID: 592487110401094201}
|
||||||
- component: {fileID: 592487110401094202}
|
- component: {fileID: 592487110401094202}
|
||||||
- component: {fileID: 592487110401094205}
|
- component: {fileID: 592487110401094205}
|
||||||
|
- component: {fileID: 4248768674552437703}
|
||||||
|
- component: {fileID: 3068808787720623988}
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: Enemy (Default Melee)
|
m_Name: Enemy (Default Melee)
|
||||||
m_TagString: Enemy
|
m_TagString: Enemy
|
||||||
@ -40,7 +42,7 @@ Transform:
|
|||||||
m_LocalPosition: {x: -0.14, y: -1.57, z: 0}
|
m_LocalPosition: {x: -0.14, y: -1.57, z: 0}
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
m_Children:
|
m_Children:
|
||||||
- {fileID: 592487111173795460}
|
- {fileID: 1801310824674407730}
|
||||||
m_Father: {fileID: 0}
|
m_Father: {fileID: 0}
|
||||||
m_RootOrder: 0
|
m_RootOrder: 0
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
@ -60,6 +62,7 @@ MonoBehaviour:
|
|||||||
Anim: {fileID: 5375970501711434365}
|
Anim: {fileID: 5375970501711434365}
|
||||||
MoveSpeed: 1
|
MoveSpeed: 1
|
||||||
BehaviourTree: {fileID: 592487110401094199}
|
BehaviourTree: {fileID: 592487110401094199}
|
||||||
|
Movement: {fileID: 4248768674552437703}
|
||||||
Attacking: 0
|
Attacking: 0
|
||||||
--- !u!50 &592487110401094195
|
--- !u!50 &592487110401094195
|
||||||
Rigidbody2D:
|
Rigidbody2D:
|
||||||
@ -265,6 +268,41 @@ MonoBehaviour:
|
|||||||
AttackAnimationLength: 0.1
|
AttackAnimationLength: 0.1
|
||||||
ReleaseAnimationLength: 0.25
|
ReleaseAnimationLength: 0.25
|
||||||
CooldownLength: 0.7
|
CooldownLength: 0.7
|
||||||
|
--- !u!114 &4248768674552437703
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 592487110401094192}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: ba61752571d0d70478c63122f73914db, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
Body: {fileID: 592487110401094195}
|
||||||
|
Bobbing: {fileID: 3068808787720623988}
|
||||||
|
Direction: {x: 0, y: 0}
|
||||||
|
MaxSpeed: 2.5
|
||||||
|
AccelerationSpeed: 10
|
||||||
|
--- !u!114 &3068808787720623988
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 592487110401094192}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: e796ba4c6f7efc449a10ed13ee42e34f, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
BobbedTransform: {fileID: 1801310824674407730}
|
||||||
|
BobbingMultiplier: 1
|
||||||
|
BobbingGravity: 0.8
|
||||||
|
BobbingLaunchSpeed: 0.12
|
||||||
|
BobbingFrequency: 0
|
||||||
|
BobbingDirection: {x: 0, y: 1}
|
||||||
--- !u!1 &592487111066334293
|
--- !u!1 &592487111066334293
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -389,11 +427,42 @@ Transform:
|
|||||||
m_PrefabInstance: {fileID: 0}
|
m_PrefabInstance: {fileID: 0}
|
||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_GameObject: {fileID: 592487111173795459}
|
m_GameObject: {fileID: 592487111173795459}
|
||||||
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, z: 0}
|
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
m_Children:
|
m_Children:
|
||||||
- {fileID: 592487111066334294}
|
- {fileID: 592487111066334294}
|
||||||
|
m_Father: {fileID: 1801310824674407730}
|
||||||
|
m_RootOrder: 0
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
--- !u!1 &7558423332818417733
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 1801310824674407730}
|
||||||
|
m_Layer: 0
|
||||||
|
m_Name: Bobbing anim
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!4 &1801310824674407730
|
||||||
|
Transform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 7558423332818417733}
|
||||||
|
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_Children:
|
||||||
|
- {fileID: 592487111173795460}
|
||||||
m_Father: {fileID: 592487110401094196}
|
m_Father: {fileID: 592487110401094196}
|
||||||
m_RootOrder: 0
|
m_RootOrder: 0
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
@ -9,8 +9,8 @@ namespace Saltosion.OneWeapon.Effects {
|
|||||||
|
|
||||||
[Range(0, 1)]
|
[Range(0, 1)]
|
||||||
public float BobbingMultiplier = 1;
|
public float BobbingMultiplier = 1;
|
||||||
public float BobbingGravity = 0.5f;
|
public float BobbingGravity = 0.8f;
|
||||||
public float BobbingLaunchSpeed = 5f;
|
public float BobbingLaunchSpeed = 0.12f;
|
||||||
|
|
||||||
public float BobbingFrequency = 0;
|
public float BobbingFrequency = 0;
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.Animations;
|
using UnityEngine.Animations;
|
||||||
using Saltosion.OneWeapon.AI;
|
using Saltosion.OneWeapon.AI;
|
||||||
|
using Saltosion.OneWeapon.Utils;
|
||||||
|
|
||||||
namespace Saltosion.OneWeapon.Enemies {
|
namespace Saltosion.OneWeapon.Enemies {
|
||||||
[RequireComponent(typeof(Rigidbody2D))]
|
[RequireComponent(typeof(Rigidbody2D))]
|
||||||
@ -13,6 +14,7 @@ namespace Saltosion.OneWeapon.Enemies {
|
|||||||
public float MoveSpeed;
|
public float MoveSpeed;
|
||||||
[Header("Behaviour")]
|
[Header("Behaviour")]
|
||||||
public BehaviourNode BehaviourTree;
|
public BehaviourNode BehaviourTree;
|
||||||
|
public AcceleratedMovement Movement;
|
||||||
|
|
||||||
[HideInInspector]
|
[HideInInspector]
|
||||||
public bool Attacking;
|
public bool Attacking;
|
||||||
@ -30,19 +32,20 @@ namespace Saltosion.OneWeapon.Enemies {
|
|||||||
CurrentBehavior = BehaviourTree.GetExecutedName();
|
CurrentBehavior = BehaviourTree.GetExecutedName();
|
||||||
|
|
||||||
if (Attacking) {
|
if (Attacking) {
|
||||||
Anim.Play("CrabAttack");
|
Anim.Play("Attack");
|
||||||
} else if (Body.velocity.magnitude > 0.1) {
|
} else if (Body.velocity.magnitude > 0.1) {
|
||||||
Anim.Play("CrabWalk");
|
Anim.Play("Walk");
|
||||||
Anim.SetFloat("Speed", 1);
|
|
||||||
} else {
|
} else {
|
||||||
Anim.Play("CrabWalk");
|
Anim.Play("Walk");
|
||||||
Anim.SetFloat("Speed", 0);
|
|
||||||
}
|
}
|
||||||
|
Anim.SetFloat("Speed", Movement.SpeedPercentage);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void FixedUpdate() {
|
private void FixedUpdate() {
|
||||||
if (MovingToTarget) {
|
if (MovingToTarget) {
|
||||||
Body.velocity = (TargetPosition - Body.position).normalized * MoveSpeed;
|
Movement.Direction = (TargetPosition - Body.position).normalized;
|
||||||
|
} else {
|
||||||
|
Movement.Direction = Vector2.zero;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,26 +63,26 @@ namespace Saltosion.OneWeapon.Player {
|
|||||||
float Rotation = Rot.z;
|
float Rotation = Rot.z;
|
||||||
|
|
||||||
if (Rotation >= 45 && Rotation < 135) {
|
if (Rotation >= 45 && Rotation < 135) {
|
||||||
BodyAnim.Play("PlayerHorizontalBody");
|
BodyAnim.Play("HorizontalBody");
|
||||||
BodySprite.flipX = false;
|
BodySprite.flipX = false;
|
||||||
HeadAnim.Play("PlayerHeadRight");
|
HeadAnim.Play("HeadRight");
|
||||||
HeadSprite.flipX = false;
|
HeadSprite.flipX = false;
|
||||||
Hand.localPosition = HandMiddle.localPosition;
|
Hand.localPosition = HandMiddle.localPosition;
|
||||||
} else if (Rotation >= 225 || Rotation < -45) {
|
} else if (Rotation >= 225 || Rotation < -45) {
|
||||||
BodyAnim.Play("PlayerHorizontalBody");
|
BodyAnim.Play("HorizontalBody");
|
||||||
BodySprite.flipX = true;
|
BodySprite.flipX = true;
|
||||||
HeadAnim.Play("PlayerHeadRight");
|
HeadAnim.Play("HeadRight");
|
||||||
HeadSprite.flipX = true;
|
HeadSprite.flipX = true;
|
||||||
Hand.localPosition = HandMiddle.localPosition;
|
Hand.localPosition = HandMiddle.localPosition;
|
||||||
} else {
|
} else {
|
||||||
if (Rotation >= 135 && Rotation < 225) {
|
if (Rotation >= 135 && Rotation < 225) {
|
||||||
HeadAnim.Play("PlayerHeadUp");
|
HeadAnim.Play("HeadUp");
|
||||||
Hand.localPosition = HandRight.localPosition;
|
Hand.localPosition = HandRight.localPosition;
|
||||||
} else {
|
} else {
|
||||||
HeadAnim.Play("PlayerHeadDown");
|
HeadAnim.Play("HeadDown");
|
||||||
Hand.localPosition = HandLeft.localPosition;
|
Hand.localPosition = HandLeft.localPosition;
|
||||||
}
|
}
|
||||||
BodyAnim.Play("PlayerVerticalBody");
|
BodyAnim.Play("VerticalBody");
|
||||||
BodySprite.flipX = false;
|
BodySprite.flipX = false;
|
||||||
HeadSprite.flipX = false;
|
HeadSprite.flipX = false;
|
||||||
}
|
}
|
||||||
|
@ -11,8 +11,8 @@ namespace Saltosion.OneWeapon.Utils {
|
|||||||
|
|
||||||
private Vector2 LastDirection = Vector2.zero;
|
private Vector2 LastDirection = Vector2.zero;
|
||||||
public Vector2 Direction = Vector2.zero;
|
public Vector2 Direction = Vector2.zero;
|
||||||
public float MaxSpeed = 50;
|
public float MaxSpeed = 7;
|
||||||
public float AccelerationSpeed = 35;
|
public float AccelerationSpeed = 70;
|
||||||
|
|
||||||
public Vector2 CurrentVelocity { private set; get; }
|
public Vector2 CurrentVelocity { private set; get; }
|
||||||
public float SpeedPercentage { private set; get; }
|
public float SpeedPercentage { private set; get; }
|
||||||
|
Loading…
Reference in New Issue
Block a user