Zombies fertig
This commit is contained in:
parent
d972e9c6c7
commit
a216ab4a2e
|
@ -10,6 +10,9 @@ GameObject:
|
|||
m_Component:
|
||||
- component: {fileID: 2715764554523923620}
|
||||
- component: {fileID: 3650884189301972455}
|
||||
- component: {fileID: 7372041109052800040}
|
||||
- component: {fileID: 7759656673043564915}
|
||||
- component: {fileID: 2818254731145199880}
|
||||
m_Layer: 0
|
||||
m_Name: GameManager
|
||||
m_TagString: Untagged
|
||||
|
@ -44,3 +47,151 @@ MonoBehaviour:
|
|||
m_Script: {fileID: 11500000, guid: 4c31bfd8f0f10f540b73de81aac6d46c, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
_difficulty: 1
|
||||
NeedFullfilledParticleEffect: {fileID: 1620116211597326, guid: 094c049ae10f1c3419c96c4bce41cf8c, type: 3}
|
||||
ZombieDeathByDisableParticleEffect: {fileID: 0}
|
||||
Needs: []
|
||||
_player: {fileID: 0}
|
||||
_totalGameDurationSeconds: 0
|
||||
_remainingGameDurationSeconds: 0
|
||||
_currentEfficiency: 0
|
||||
_generalNeedDrainScaling: 0.001
|
||||
_developers:
|
||||
- {fileID: 0}
|
||||
- {fileID: 0}
|
||||
- {fileID: 0}
|
||||
- {fileID: 0}
|
||||
_gameRunning:
|
||||
_falseness: 1
|
||||
_needNotificationThreshold: 0.25
|
||||
_maxContextBufferSize: 3
|
||||
--- !u!114 &7372041109052800040
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2703668081068178613}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: c18f377723b64fd8a8d0261b85b3ba48, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
_daysUntilRelease: 7
|
||||
_secondsPerDay: 120
|
||||
_totalTime: 0
|
||||
_sun: {fileID: 0}
|
||||
--- !u!114 &7759656673043564915
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2703668081068178613}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 8f523547bf5e54c4989863475e2bdbaf, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
_ambientMusic:
|
||||
- {fileID: 8300000, guid: 680bb3ce77c09334998b4c94313049d0, type: 3}
|
||||
- {fileID: 8300000, guid: 71646a2bfa6761d47ace4395791decfe, type: 3}
|
||||
- {fileID: 8300000, guid: 95f03e199fce21c4c92959821c685f3d, type: 3}
|
||||
_showDownMusic: {fileID: 8300000, guid: 608315f6bbecbd94e8e3bc4e16f7a429, type: 3}
|
||||
_musicTimer: 5
|
||||
--- !u!82 &2818254731145199880
|
||||
AudioSource:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2703668081068178613}
|
||||
m_Enabled: 1
|
||||
serializedVersion: 4
|
||||
OutputAudioMixerGroup: {fileID: 0}
|
||||
m_audioClip: {fileID: 0}
|
||||
m_PlayOnAwake: 1
|
||||
m_Volume: 0.3
|
||||
m_Pitch: 1
|
||||
Loop: 0
|
||||
Mute: 0
|
||||
Spatialize: 0
|
||||
SpatializePostEffects: 0
|
||||
Priority: 32
|
||||
DopplerLevel: 1
|
||||
MinDistance: 1
|
||||
MaxDistance: 500
|
||||
Pan2D: 0
|
||||
rolloffMode: 0
|
||||
BypassEffects: 0
|
||||
BypassListenerEffects: 0
|
||||
BypassReverbZones: 0
|
||||
rolloffCustomCurve:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 3
|
||||
time: 0
|
||||
value: 1
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
- serializedVersion: 3
|
||||
time: 1
|
||||
value: 0
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
panLevelCustomCurve:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 3
|
||||
time: 0
|
||||
value: 0
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
spreadCustomCurve:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 3
|
||||
time: 0
|
||||
value: 0
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
reverbZoneMixCustomCurve:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 3
|
||||
time: 0
|
||||
value: 1
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
|
|
|
@ -92,8 +92,8 @@ Transform:
|
|||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 856601670117699726}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 1, z: 0, w: -0.00000016292068}
|
||||
m_LocalPosition: {x: -3.86, y: 0, z: 0}
|
||||
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:
|
||||
|
@ -138,12 +138,16 @@ MonoBehaviour:
|
|||
- {fileID: 8300000, guid: 866ac9f78eeaf514aa666667753ff280, type: 3}
|
||||
- {fileID: 8300000, guid: daa3c8aa3194de542ab4aa911886644b, type: 3}
|
||||
- {fileID: 8300000, guid: 559ec60d7a147d14dbbfc776266dad5e, type: 3}
|
||||
_speed: 0.3
|
||||
_rotateSpeed: 180
|
||||
_attackRange: 0.8
|
||||
_idleThresholdFactor: 0.12
|
||||
_speed: 0.5
|
||||
_rotateSpeed: 270
|
||||
_attackRange: 1.5
|
||||
_jumpForce: 6
|
||||
_idleThresholdFactor: 3
|
||||
_noiseDelay: 4
|
||||
_noiseTimer: 0
|
||||
_groundLayer:
|
||||
serializedVersion: 2
|
||||
m_Bits: 8
|
||||
--- !u!54 &7592819367808213806
|
||||
Rigidbody:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -152,8 +156,8 @@ Rigidbody:
|
|||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 856601670117699726}
|
||||
serializedVersion: 4
|
||||
m_Mass: 1
|
||||
m_Drag: 0
|
||||
m_Mass: 30
|
||||
m_Drag: 1
|
||||
m_AngularDrag: 0.05
|
||||
m_CenterOfMass: {x: 0, y: 0, z: 0}
|
||||
m_InertiaTensor: {x: 1, y: 1, z: 1}
|
||||
|
@ -166,7 +170,7 @@ Rigidbody:
|
|||
m_Bits: 0
|
||||
m_ImplicitCom: 1
|
||||
m_ImplicitTensor: 1
|
||||
m_UseGravity: 0
|
||||
m_UseGravity: 1
|
||||
m_IsKinematic: 0
|
||||
m_Interpolate: 0
|
||||
m_Constraints: 80
|
||||
|
@ -206,13 +210,13 @@ AudioSource:
|
|||
OutputAudioMixerGroup: {fileID: 0}
|
||||
m_audioClip: {fileID: 0}
|
||||
m_PlayOnAwake: 1
|
||||
m_Volume: 1
|
||||
m_Volume: 0.5
|
||||
m_Pitch: 1
|
||||
Loop: 0
|
||||
Mute: 0
|
||||
Spatialize: 0
|
||||
SpatializePostEffects: 0
|
||||
Priority: 128
|
||||
Priority: 69
|
||||
DopplerLevel: 1
|
||||
MinDistance: 1
|
||||
MaxDistance: 500
|
||||
|
|
|
@ -12,6 +12,7 @@ AnimatorState:
|
|||
m_CycleOffset: 0
|
||||
m_Transitions:
|
||||
- {fileID: -2499677071233001700}
|
||||
- {fileID: -6471167266255213614}
|
||||
m_StateMachineBehaviours: []
|
||||
m_Position: {x: 50, y: 50, z: 0}
|
||||
m_IKOnFeet: 0
|
||||
|
@ -77,6 +78,31 @@ AnimatorStateMachine:
|
|||
m_ExitPosition: {x: 110, y: 510, z: 0}
|
||||
m_ParentStateMachinePosition: {x: 800, y: 20, z: 0}
|
||||
m_DefaultState: {fileID: 3345498408644874919}
|
||||
--- !u!1101 &-6471167266255213614
|
||||
AnimatorStateTransition:
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name:
|
||||
m_Conditions:
|
||||
- m_ConditionMode: 1
|
||||
m_ConditionEvent: Attack
|
||||
m_EventTreshold: 0
|
||||
m_DstStateMachine: {fileID: 0}
|
||||
m_DstState: {fileID: -4338890450920113477}
|
||||
m_Solo: 0
|
||||
m_Mute: 0
|
||||
m_IsExit: 0
|
||||
serializedVersion: 3
|
||||
m_TransitionDuration: 0.25000003
|
||||
m_TransitionOffset: 0
|
||||
m_ExitTime: 0.019070633
|
||||
m_HasExitTime: 0
|
||||
m_HasFixedDuration: 1
|
||||
m_InterruptionSource: 0
|
||||
m_OrderedInterruption: 1
|
||||
m_CanTransitionToSelf: 1
|
||||
--- !u!1101 &-4935679139000002796
|
||||
AnimatorStateTransition:
|
||||
m_ObjectHideFlags: 1
|
||||
|
@ -137,9 +163,6 @@ AnimatorStateTransition:
|
|||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name:
|
||||
m_Conditions:
|
||||
- m_ConditionMode: 1
|
||||
m_ConditionEvent: Attack
|
||||
m_EventTreshold: 0
|
||||
- m_ConditionMode: 1
|
||||
m_ConditionEvent: Idle
|
||||
m_EventTreshold: 0
|
||||
|
@ -174,19 +197,19 @@ AnimatorController:
|
|||
m_DefaultFloat: 0
|
||||
m_DefaultInt: 0
|
||||
m_DefaultBool: 0
|
||||
m_Controller: {fileID: 0}
|
||||
m_Controller: {fileID: 9100000}
|
||||
- m_Name: Idle
|
||||
m_Type: 4
|
||||
m_DefaultFloat: 0
|
||||
m_DefaultInt: 0
|
||||
m_DefaultBool: 1
|
||||
m_Controller: {fileID: 0}
|
||||
m_Controller: {fileID: 9100000}
|
||||
- m_Name: Attack
|
||||
m_Type: 4
|
||||
m_DefaultFloat: 0
|
||||
m_DefaultInt: 0
|
||||
m_DefaultBool: 0
|
||||
m_Controller: {fileID: 0}
|
||||
m_Controller: {fileID: 9100000}
|
||||
m_AnimatorLayers:
|
||||
- serializedVersion: 5
|
||||
m_Name: Base Layer
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -20,11 +20,15 @@ public class Zombie : MonoBehaviour
|
|||
[SerializeField]
|
||||
private float _attackRange = 1.3f;
|
||||
[SerializeField]
|
||||
private float _jumpForce;
|
||||
[SerializeField]
|
||||
private float _idleThresholdFactor = 0.2f;
|
||||
[SerializeField]
|
||||
private float _noiseDelay = 5.0f;
|
||||
[SerializeField, ShowOnly]
|
||||
private float _noiseTimer;
|
||||
[SerializeField]
|
||||
private LayerMask _groundLayer;
|
||||
|
||||
private Rigidbody _rb;
|
||||
private AudioSource _audioSource;
|
||||
|
@ -32,7 +36,7 @@ public class Zombie : MonoBehaviour
|
|||
private Animator _animator;
|
||||
private bool _isAttacking = false;
|
||||
private float _idleThreshold;
|
||||
private Quaternion _initialRotation;
|
||||
private Vector3 _initialPosition;
|
||||
|
||||
|
||||
|
||||
|
@ -49,7 +53,7 @@ public class Zombie : MonoBehaviour
|
|||
_audioSource = GetComponent<AudioSource>();
|
||||
_animator = GetComponent<Animator>();
|
||||
_idleThreshold = _speed / _idleThresholdFactor;
|
||||
_initialRotation = transform.rotation;
|
||||
_initialPosition = transform.position;
|
||||
}
|
||||
|
||||
void Update()
|
||||
|
@ -67,8 +71,9 @@ void Update()
|
|||
{
|
||||
Vector3 direction = (GameManager.Instance.Player.transform.position - transform.position);
|
||||
Quaternion goalRotation = Quaternion.LookRotation(direction);
|
||||
transform.rotation = Quaternion.RotateTowards(transform.rotation, goalRotation, _rotateSpeed * Time.deltaTime);
|
||||
transform.rotation = Quaternion.Euler(0, Quaternion.RotateTowards(transform.rotation, goalRotation, _rotateSpeed * Time.deltaTime).eulerAngles.y, 0);
|
||||
float diff = direction.magnitude;
|
||||
//Debug.Log(diff);
|
||||
if (diff <= _attackRange && !_isAttacking)
|
||||
{
|
||||
_animator.SetFloat("Running", 0);
|
||||
|
@ -78,12 +83,21 @@ void Update()
|
|||
else
|
||||
{
|
||||
Vector3 oldPosition = _rb.position;
|
||||
_rb.MovePosition(_rb.position + direction * _speed * Time.deltaTime);
|
||||
Vector3 goalDirection = new Vector3(direction.x, 0.2f, direction.z);
|
||||
if (Physics.Raycast(transform.position + new Vector3(0, 0.1f, 0), goalDirection, 1f, _groundLayer))
|
||||
{
|
||||
Debug.Log("RayCast HIT");
|
||||
//_rb.AddForce(Vector3.up * _jumpForce, ForceMode.Impulse);
|
||||
_rb.MovePosition(_rb.position - transform.forward * Time.deltaTime);
|
||||
_rb.MovePosition(_rb.position + new Vector3(0, _jumpForce, 0) * Time.deltaTime);
|
||||
}
|
||||
_rb.MovePosition(_rb.position + goalDirection * _speed * Time.deltaTime);
|
||||
float dist = Vector3.Distance(oldPosition, _rb.position);
|
||||
//Debug.Log($"Distance: {dist}, Threshold: {_idleThreshold * Time.deltaTime}");
|
||||
if (dist > _idleThreshold * Time.deltaTime)
|
||||
{
|
||||
_animator.SetBool("Idle", false);
|
||||
_animator.SetFloat("Running", 1);
|
||||
_animator.SetFloat("Running", _speed * 3.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -97,12 +111,12 @@ void Update()
|
|||
{
|
||||
_isAttacking = true;
|
||||
_animator.SetBool("Attack", true);
|
||||
yield return new WaitForSeconds(1.5f);
|
||||
yield return new WaitForSeconds(0.5f);
|
||||
_animator.SetBool("Attack", false);
|
||||
// check if actually hit
|
||||
Vector3 direction = (GameManager.Instance.Player.transform.position - transform.position);
|
||||
float diff = direction.magnitude;
|
||||
if (diff <= _attackRange + 0.5f)
|
||||
if (diff <= _attackRange + 0.6f)
|
||||
{
|
||||
GameManager.Instance.Player.GetComponent<Character>().PickupItem(null);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue