Base done

This commit is contained in:
Gerard Gascón 2023-08-09 20:07:47 +02:00
parent 32f5ed6299
commit 6ba30e430e
16 changed files with 828 additions and 42 deletions

View file

@ -0,0 +1,101 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1102 &-8292058200286035580
AnimatorState:
serializedVersion: 6
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: EnemyDie
m_Speed: 1
m_CycleOffset: 0
m_Transitions: []
m_StateMachineBehaviours: []
m_Position: {x: 50, y: 50, z: 0}
m_IKOnFeet: 0
m_WriteDefaultValues: 1
m_Mirror: 0
m_SpeedParameterActive: 0
m_MirrorParameterActive: 0
m_CycleOffsetParameterActive: 0
m_TimeParameterActive: 0
m_Motion: {fileID: 7400000, guid: e0cdd25bc58572e4db6cf91f7803dfd0, type: 2}
m_Tag:
m_SpeedParameter:
m_MirrorParameter:
m_CycleOffsetParameter:
m_TimeParameter:
--- !u!1107 &-3884682661882762159
AnimatorStateMachine:
serializedVersion: 6
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Base Layer
m_ChildStates:
- serializedVersion: 1
m_State: {fileID: 7866682912205201252}
m_Position: {x: 200, y: 0, z: 0}
- serializedVersion: 1
m_State: {fileID: -8292058200286035580}
m_Position: {x: 235, y: 65, z: 0}
m_ChildStateMachines: []
m_AnyStateTransitions: []
m_EntryTransitions: []
m_StateMachineTransitions: {}
m_StateMachineBehaviours: []
m_AnyStatePosition: {x: 50, y: 20, z: 0}
m_EntryPosition: {x: 50, y: 120, z: 0}
m_ExitPosition: {x: 800, y: 120, z: 0}
m_ParentStateMachinePosition: {x: 800, y: 20, z: 0}
m_DefaultState: {fileID: 7866682912205201252}
--- !u!91 &9100000
AnimatorController:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Enemy
serializedVersion: 5
m_AnimatorParameters: []
m_AnimatorLayers:
- serializedVersion: 5
m_Name: Base Layer
m_StateMachine: {fileID: -3884682661882762159}
m_Mask: {fileID: 0}
m_Motions: []
m_Behaviours: []
m_BlendingMode: 0
m_SyncedLayerIndex: -1
m_DefaultWeight: 0
m_IKPass: 0
m_SyncedLayerAffectsTiming: 0
m_Controller: {fileID: 9100000}
--- !u!1102 &7866682912205201252
AnimatorState:
serializedVersion: 6
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: EnemyWalk
m_Speed: 1
m_CycleOffset: 0
m_Transitions: []
m_StateMachineBehaviours: []
m_Position: {x: 50, y: 50, z: 0}
m_IKOnFeet: 0
m_WriteDefaultValues: 1
m_Mirror: 0
m_SpeedParameterActive: 0
m_MirrorParameterActive: 0
m_CycleOffsetParameterActive: 0
m_TimeParameterActive: 0
m_Motion: {fileID: 7400000, guid: d8ca2bcdf8122fd47a5fff53626e2e43, type: 2}
m_Tag:
m_SpeedParameter:
m_MirrorParameter:
m_CycleOffsetParameter:
m_TimeParameter:

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: bd5389f2f4813774ab1844173ff37005
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 9100000
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,68 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!74 &7400000
AnimationClip:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: EnemyDie
serializedVersion: 6
m_Legacy: 0
m_Compressed: 0
m_UseHighQualityCurve: 1
m_RotationCurves: []
m_CompressedRotationCurves: []
m_EulerCurves: []
m_PositionCurves: []
m_ScaleCurves: []
m_FloatCurves: []
m_PPtrCurves:
- curve:
- time: 0
value: {fileID: -1052054766, guid: d0dc440f4f15a9443abd4026a0afb473, type: 3}
attribute: m_Sprite
path: Sprite
classID: 212
script: {fileID: 0}
m_SampleRate: 60
m_WrapMode: 0
m_Bounds:
m_Center: {x: 0, y: 0, z: 0}
m_Extent: {x: 0, y: 0, z: 0}
m_ClipBindingConstant:
genericBindings:
- serializedVersion: 2
path: 850496168
attribute: 0
script: {fileID: 0}
typeID: 212
customType: 23
isPPtrCurve: 1
pptrCurveMapping:
- {fileID: -1052054766, guid: d0dc440f4f15a9443abd4026a0afb473, type: 3}
m_AnimationClipSettings:
serializedVersion: 2
m_AdditiveReferencePoseClip: {fileID: 0}
m_AdditiveReferencePoseTime: 0
m_StartTime: 0
m_StopTime: 0.016666668
m_OrientationOffsetY: 0
m_Level: 0
m_CycleOffset: 0
m_HasAdditiveReferencePose: 0
m_LoopTime: 1
m_LoopBlend: 0
m_LoopBlendOrientation: 0
m_LoopBlendPositionY: 0
m_LoopBlendPositionXZ: 0
m_KeepOriginalOrientation: 0
m_KeepOriginalPositionY: 1
m_KeepOriginalPositionXZ: 0
m_HeightFromFeet: 0
m_Mirror: 0
m_EditorCurves: []
m_EulerEditorCurves: []
m_HasGenericRootTransform: 0
m_HasMotionFloatCurves: 0
m_Events: []

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: e0cdd25bc58572e4db6cf91f7803dfd0
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 7400000
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,74 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!74 &7400000
AnimationClip:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: EnemyWalk
serializedVersion: 6
m_Legacy: 0
m_Compressed: 0
m_UseHighQualityCurve: 1
m_RotationCurves: []
m_CompressedRotationCurves: []
m_EulerCurves: []
m_PositionCurves: []
m_ScaleCurves: []
m_FloatCurves: []
m_PPtrCurves:
- curve:
- time: 0
value: {fileID: 319719716, guid: d0dc440f4f15a9443abd4026a0afb473, type: 3}
- time: 0.083333336
value: {fileID: -756507726, guid: d0dc440f4f15a9443abd4026a0afb473, type: 3}
- time: 0.16666667
value: {fileID: -756507726, guid: d0dc440f4f15a9443abd4026a0afb473, type: 3}
attribute: m_Sprite
path: Sprite
classID: 212
script: {fileID: 0}
m_SampleRate: 60
m_WrapMode: 0
m_Bounds:
m_Center: {x: 0, y: 0, z: 0}
m_Extent: {x: 0, y: 0, z: 0}
m_ClipBindingConstant:
genericBindings:
- serializedVersion: 2
path: 850496168
attribute: 0
script: {fileID: 0}
typeID: 212
customType: 23
isPPtrCurve: 1
pptrCurveMapping:
- {fileID: 319719716, guid: d0dc440f4f15a9443abd4026a0afb473, type: 3}
- {fileID: -756507726, guid: d0dc440f4f15a9443abd4026a0afb473, type: 3}
- {fileID: -756507726, guid: d0dc440f4f15a9443abd4026a0afb473, type: 3}
m_AnimationClipSettings:
serializedVersion: 2
m_AdditiveReferencePoseClip: {fileID: 0}
m_AdditiveReferencePoseTime: 0
m_StartTime: 0
m_StopTime: 0.18333334
m_OrientationOffsetY: 0
m_Level: 0
m_CycleOffset: 0
m_HasAdditiveReferencePose: 0
m_LoopTime: 1
m_LoopBlend: 0
m_LoopBlendOrientation: 0
m_LoopBlendPositionY: 0
m_LoopBlendPositionXZ: 0
m_KeepOriginalOrientation: 0
m_KeepOriginalPositionY: 1
m_KeepOriginalPositionXZ: 0
m_HeightFromFeet: 0
m_Mirror: 0
m_EditorCurves: []
m_EulerEditorCurves: []
m_HasGenericRootTransform: 0
m_HasMotionFloatCurves: 0
m_Events: []

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: d8ca2bcdf8122fd47a5fff53626e2e43
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 7400000
userData:
assetBundleName:
assetBundleVariant:

343
Assets/Prefabs/Enemy.prefab Normal file
View file

@ -0,0 +1,343 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &4647122662011115854
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 4647122662011115857}
m_Layer: 0
m_Name: FlippingPivotLeft
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &4647122662011115857
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4647122662011115854}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -0.25, y: 0.25, z: 0}
m_LocalScale: {x: 0.0625, y: 0.25, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 4647122663633710291}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &4647122662175001819
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 4647122662175001818}
- component: {fileID: 4647122662175001821}
m_Layer: 0
m_Name: Sprite
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &4647122662175001818
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4647122662175001819}
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: []
m_Father: {fileID: 4647122663633710291}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!212 &4647122662175001821
SpriteRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4647122662175001819}
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 0
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 0
m_RayTraceProcedural: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: a97c105638bdf8b4a8650670310a4cd3, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 0
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_Sprite: {fileID: 319719716, guid: d0dc440f4f15a9443abd4026a0afb473, type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_FlipX: 0
m_FlipY: 0
m_DrawMode: 0
m_Size: {x: 0.5, y: 0.65625}
m_AdaptiveModeThreshold: 0.5
m_SpriteTileMode: 0
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!1 &4647122662348553276
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 4647122662348553279}
- component: {fileID: 4647122662348553278}
- component: {fileID: 4647122662348553281}
m_Layer: 0
m_Name: WeakPoint
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &4647122662348553279
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4647122662348553276}
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: []
m_Father: {fileID: 4647122663633710291}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!61 &4647122662348553278
BoxCollider2D:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4647122662348553276}
m_Enabled: 1
m_Density: 1
m_Material: {fileID: 0}
m_IsTrigger: 1
m_UsedByEffector: 0
m_UsedByComposite: 0
m_Offset: {x: -0.0010737181, y: 0.48966092}
m_SpriteTilingProperty:
border: {x: 0, y: 0, z: 0, w: 0}
pivot: {x: 0, y: 0}
oldSize: {x: 0, y: 0}
newSize: {x: 0, y: 0}
adaptiveTilingThreshold: 0
drawMode: 0
adaptiveTiling: 0
m_AutoTiling: 0
serializedVersion: 2
m_Size: {x: 0.43517184, y: 0.19248903}
m_EdgeRadius: 0
--- !u!114 &4647122662348553281
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4647122662348553276}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 6dbb9bbb794a4ef0acd40077f0ccb5b3, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &4647122662407435988
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 4647122662407435991}
m_Layer: 0
m_Name: FlippingPivotRight
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &4647122662407435991
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4647122662407435988}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0.25, y: 0.25, z: 0}
m_LocalScale: {x: 0.0625, y: 0.25, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 4647122663633710291}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &4647122663633710289
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 4647122663633710291}
- component: {fileID: 4647122663633710288}
- component: {fileID: 4647122663633710293}
- component: {fileID: 4647122663633710290}
- component: {fileID: 4647122663633710292}
m_Layer: 0
m_Name: Enemy
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &4647122663633710291
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4647122663633710289}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 2, y: -2, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 4647122662175001818}
- {fileID: 4647122662011115857}
- {fileID: 4647122662407435991}
- {fileID: 4647122662348553279}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!95 &4647122663633710288
Animator:
serializedVersion: 4
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4647122663633710289}
m_Enabled: 1
m_Avatar: {fileID: 0}
m_Controller: {fileID: 9100000, guid: bd5389f2f4813774ab1844173ff37005, type: 2}
m_CullingMode: 0
m_UpdateMode: 0
m_ApplyRootMotion: 0
m_LinearVelocityBlending: 0
m_StabilizeFeet: 0
m_WarningMessage:
m_HasTransformHierarchy: 1
m_AllowConstantClipSamplingOptimization: 1
m_KeepAnimatorControllerStateOnDisable: 0
--- !u!61 &4647122663633710293
BoxCollider2D:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4647122663633710289}
m_Enabled: 1
m_Density: 1
m_Material: {fileID: 6200000, guid: 25179f3547a61ca4fa99c94bd3e0ae5e, type: 2}
m_IsTrigger: 0
m_UsedByEffector: 0
m_UsedByComposite: 0
m_Offset: {x: 0, y: 0.25}
m_SpriteTilingProperty:
border: {x: 0, y: 0, z: 0, w: 0}
pivot: {x: 0, y: 0}
oldSize: {x: 0, y: 0}
newSize: {x: 0, y: 0}
adaptiveTilingThreshold: 0
drawMode: 0
adaptiveTiling: 0
m_AutoTiling: 0
serializedVersion: 2
m_Size: {x: 0.5, y: 0.5}
m_EdgeRadius: 0
--- !u!50 &4647122663633710290
Rigidbody2D:
serializedVersion: 4
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4647122663633710289}
m_BodyType: 0
m_Simulated: 1
m_UseFullKinematicContacts: 0
m_UseAutoMass: 0
m_Mass: 1
m_LinearDrag: 0
m_AngularDrag: 0.05
m_GravityScale: 1
m_Material: {fileID: 6200000, guid: 25179f3547a61ca4fa99c94bd3e0ae5e, type: 2}
m_Interpolate: 1
m_SleepingMode: 1
m_CollisionDetection: 0
m_Constraints: 4
--- !u!114 &4647122663633710292
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4647122663633710289}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: de0543dd18c7f9945a8e617c8a7a8f30, type: 3}
m_Name:
m_EditorClassIdentifier:
speed: 5
groundLayer:
serializedVersion: 2
m_Bits: 8
flippingPivotLeft: {fileID: 4647122662011115857}
flippingPivotRight: {fileID: 4647122662407435991}

View file

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 861b452034207444d950b2e58aaa88c6
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

47
Assets/Scripts/Enemy1.cs Normal file
View file

@ -0,0 +1,47 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Enemy1 : MonoBehaviour {
[SerializeField] float speed;
[SerializeField] LayerMask groundLayer;
[Header("Flipping Pivots")]
[SerializeField] Transform flippingPivotLeft;
[SerializeField] Transform flippingPivotRight;
int _facingDirection = 1;
Rigidbody2D _rb;
// Start is called before the first frame update
void Awake() {
_rb = GetComponent<Rigidbody2D>();
}
// Update is called once per frame
void FixedUpdate() {
if (_facingDirection > 0) {
if (Physics2D.OverlapBox(flippingPivotRight.position, flippingPivotRight.localScale, 0, groundLayer)) {
_facingDirection = -1;
transform.localScale = new Vector3(-1, 1, 1);
}
}else {
if (Physics2D.OverlapBox(flippingPivotLeft.position, flippingPivotLeft.localScale, 0, groundLayer)) {
_facingDirection = 1;
transform.localScale = Vector3.one;
}
}
_rb.velocity = new Vector2(speed * _facingDirection, _rb.velocity.y);
}
void OnDrawGizmos() {
if(!flippingPivotLeft || !flippingPivotRight) return;
Gizmos.color = Color.red;
Gizmos.DrawWireCube(flippingPivotLeft.position, flippingPivotLeft.localScale);
Gizmos.DrawWireCube(flippingPivotRight.position, flippingPivotRight.localScale);
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: de0543dd18c7f9945a8e617c8a7a8f30
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,20 @@
using System;
using UnityEngine;
public class EnemyWeakPoint1 : MonoBehaviour {
Enemy1 _enemy;
void Awake() {
_enemy = GetComponentInParent<Enemy1>();
}
void OnTriggerEnter2D(Collider2D other) {
if (!other.CompareTag("Player")) return;
PlayerMovement1 player = other.GetComponent<PlayerMovement1>();
player.Rb.velocity = new Vector2(player.Rb.velocity.x, player.deathForce);
player.Animator.SetTrigger(PlayerMovement1.Jump1);
Destroy(_enemy.gameObject);
}
}

View file

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 6dbb9bbb794a4ef0acd40077f0ccb5b3
timeCreated: 1691603524

View file

@ -4,6 +4,7 @@ using UnityEngine.InputSystem;
public class PlayerMovement1 : MonoBehaviour {
public float deathForce = 8f;
[SerializeField] float speed = 5f;
[SerializeField] float jumpForce = 10f;
@ -20,19 +21,21 @@ public class PlayerMovement1 : MonoBehaviour {
int _facingDirection = 1;
Rigidbody2D _rb;
public Rigidbody2D Rb { get; private set; }
PlayerInput _playerInput;
[Header("Animations")]
[SerializeField] Animator animator;
public Animator Animator => animator;
static readonly int Jump1 = Animator.StringToHash("Jump");
public static readonly int Jump1 = Animator.StringToHash("Jump");
static readonly int XVelocity = Animator.StringToHash("xVelocity");
static readonly int YVelocity = Animator.StringToHash("yVelocity");
static readonly int Grounded = Animator.StringToHash("Grounded");
void Awake() {
_rb = GetComponent<Rigidbody2D>();
Rb = GetComponent<Rigidbody2D>();
_playerInput = new PlayerInput();
@ -47,7 +50,7 @@ public class PlayerMovement1 : MonoBehaviour {
void Jump(InputAction.CallbackContext obj) {
if (!_grounded) return;
_rb.velocity = new Vector2(_rb.velocity.x, jumpForce);
Rb.velocity = new Vector2(Rb.velocity.x, jumpForce);
animator.SetTrigger(Jump1);
}
@ -73,13 +76,13 @@ public class PlayerMovement1 : MonoBehaviour {
// Update is called once per frame
void Update() {
animator.SetFloat(XVelocity, Mathf.Abs(_horizontalInput * speed));
animator.SetFloat(YVelocity, _rb.velocity.y);
animator.SetFloat(YVelocity, Rb.velocity.y);
animator.SetBool(Grounded, _grounded);
}
void FixedUpdate() {
_grounded = Physics2D.OverlapBox(transform.position, feetSize, 0, groundMask);
_rb.velocity = new Vector2(_horizontalInput * speed, _rb.velocity.y);
Rb.velocity = new Vector2(_horizontalInput * speed, Rb.velocity.y);
}
void OnDrawGizmos() {

View file

@ -73,6 +73,10 @@ MonoBehaviour:
instantiationMode: 0
- dependency: {fileID: 11400000, guid: f00f679a303f58e41b4d1cfb8623ebee, type: 2}
instantiationMode: 1
- dependency: {fileID: 2800000, guid: d0dc440f4f15a9443abd4026a0afb473, type: 3}
instantiationMode: 0
- dependency: {fileID: 4647122663633710289, guid: 861b452034207444d950b2e58aaa88c6, type: 3}
instantiationMode: 0
- dependency: {fileID: 11400000, guid: 8501dbe4b7dd5ff4f822e1a4ac9e80ed, type: 2}
instantiationMode: 1
- dependency: {fileID: 5002620220514089441, guid: 8dac3d75191987d42bab1c1eeeb821e2, type: 3}
@ -85,6 +89,8 @@ MonoBehaviour:
instantiationMode: 0
- dependency: {fileID: 6200000, guid: 25179f3547a61ca4fa99c94bd3e0ae5e, type: 2}
instantiationMode: 0
- dependency: {fileID: 7400000, guid: e0cdd25bc58572e4db6cf91f7803dfd0, type: 2}
instantiationMode: 0
- dependency: {fileID: 11400000, guid: 2479ec43d60603e4b850d860ccdeaf2e, type: 2}
instantiationMode: 1
- dependency: {fileID: 2100000, guid: a97c105638bdf8b4a8650670310a4cd3, type: 2}
@ -93,6 +99,8 @@ MonoBehaviour:
instantiationMode: 0
- dependency: {fileID: 11400000, guid: adce3ba3673dac84abc56713716b4fd2, type: 2}
instantiationMode: 1
- dependency: {fileID: 9100000, guid: bd5389f2f4813774ab1844173ff37005, type: 2}
instantiationMode: 0
- dependency: {fileID: 11400000, guid: 50f6ddfd6ba5fab4aa175bc100e13069, type: 2}
instantiationMode: 1
- dependency: {fileID: 11400000, guid: cf5114de2413f1941b110701c5d7b625, type: 2}
@ -103,6 +111,8 @@ MonoBehaviour:
instantiationMode: 1
- dependency: {fileID: 11400000, guid: c70c103a8240a804e8bd2f5d3745c6dc, type: 2}
instantiationMode: 1
- dependency: {fileID: 7400000, guid: d8ca2bcdf8122fd47a5fff53626e2e43, type: 2}
instantiationMode: 0
- dependency: {fileID: 2800000, guid: 5f2a108eb023faf43a809979fd3d38f2, type: 3}
instantiationMode: 0
- dependency: {fileID: 2800000, guid: b8ba3923a6094cd48b85425f47fd7450, type: 3}

View file

@ -7607,7 +7607,7 @@ GameObject:
- component: {fileID: 1728226841}
m_Layer: 6
m_Name: Player
m_TagString: Untagged
m_TagString: Player
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
@ -7688,6 +7688,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 35101a1f20646064487d119d6d32898b, type: 3}
m_Name:
m_EditorClassIdentifier:
deathForce: 8
speed: 5
jumpForce: 8
bullet: {fileID: 5483207318563873678, guid: 8dac3d75191987d42bab1c1eeeb821e2, type: 3}
@ -8453,3 +8454,60 @@ SpriteRenderer:
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!1001 &4647122663651305217
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 4647122663633710289, guid: 861b452034207444d950b2e58aaa88c6, type: 3}
propertyPath: m_Name
value: Enemy
objectReference: {fileID: 0}
- target: {fileID: 4647122663633710291, guid: 861b452034207444d950b2e58aaa88c6, type: 3}
propertyPath: m_RootOrder
value: 7
objectReference: {fileID: 0}
- target: {fileID: 4647122663633710291, guid: 861b452034207444d950b2e58aaa88c6, type: 3}
propertyPath: m_LocalPosition.x
value: 2
objectReference: {fileID: 0}
- target: {fileID: 4647122663633710291, guid: 861b452034207444d950b2e58aaa88c6, type: 3}
propertyPath: m_LocalPosition.y
value: -2
objectReference: {fileID: 0}
- target: {fileID: 4647122663633710291, guid: 861b452034207444d950b2e58aaa88c6, type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4647122663633710291, guid: 861b452034207444d950b2e58aaa88c6, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 4647122663633710291, guid: 861b452034207444d950b2e58aaa88c6, type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4647122663633710291, guid: 861b452034207444d950b2e58aaa88c6, type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4647122663633710291, guid: 861b452034207444d950b2e58aaa88c6, type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4647122663633710291, guid: 861b452034207444d950b2e58aaa88c6, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4647122663633710291, guid: 861b452034207444d950b2e58aaa88c6, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4647122663633710291, guid: 861b452034207444d950b2e58aaa88c6, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 861b452034207444d950b2e58aaa88c6, type: 3}

View file

@ -19,7 +19,7 @@ MonoBehaviour:
width: 3072
height: 1636.8
m_ShowMode: 4
m_Title: Scene
m_Title: Game
m_RootView: {fileID: 2}
m_MinSize: {x: 875, y: 350}
m_MaxSize: {x: 10000, y: 10000}
@ -119,7 +119,7 @@ MonoBehaviour:
m_MinSize: {x: 300, y: 200}
m_MaxSize: {x: 24288, y: 16192}
vertical: 0
controlID: 21
controlID: 101
--- !u!114 &6
MonoBehaviour:
m_ObjectHideFlags: 52
@ -144,7 +144,7 @@ MonoBehaviour:
m_MinSize: {x: 200, y: 200}
m_MaxSize: {x: 16192, y: 16192}
vertical: 1
controlID: 22
controlID: 102
--- !u!114 &7
MonoBehaviour:
m_ObjectHideFlags: 52
@ -155,7 +155,7 @@ MonoBehaviour:
m_Enabled: 1
m_EditorHideFlags: 1
m_Script: {fileID: 12006, guid: 0000000000000000e000000000000000, type: 0}
m_Name: SceneView
m_Name: GameView
m_EditorClassIdentifier:
m_Children: []
m_Position:
@ -164,16 +164,16 @@ MonoBehaviour:
y: 0
width: 2365.6
height: 1111.2
m_MinSize: {x: 201, y: 221}
m_MaxSize: {x: 4001, y: 4021}
m_ActualView: {fileID: 16}
m_MinSize: {x: 200, y: 200}
m_MaxSize: {x: 4000, y: 4000}
m_ActualView: {fileID: 15}
m_Panes:
- {fileID: 16}
- {fileID: 15}
- {fileID: 14}
- {fileID: 13}
m_Selected: 0
m_LastSelected: 1
m_Selected: 1
m_LastSelected: 3
--- !u!114 &8
MonoBehaviour:
m_ObjectHideFlags: 52
@ -198,7 +198,7 @@ MonoBehaviour:
m_MinSize: {x: 200, y: 100}
m_MaxSize: {x: 16192, y: 8096}
vertical: 0
controlID: 34
controlID: 47
--- !u!114 &9
MonoBehaviour:
m_ObjectHideFlags: 52
@ -218,8 +218,8 @@ MonoBehaviour:
y: 0
width: 370.4
height: 475.6001
m_MinSize: {x: 201, y: 221}
m_MaxSize: {x: 4001, y: 4021}
m_MinSize: {x: 200, y: 200}
m_MaxSize: {x: 4000, y: 4000}
m_ActualView: {fileID: 17}
m_Panes:
- {fileID: 17}
@ -252,7 +252,7 @@ MonoBehaviour:
- {fileID: 19}
- {fileID: 12}
m_Selected: 0
m_LastSelected: 2
m_LastSelected: 1
--- !u!114 &11
MonoBehaviour:
m_ObjectHideFlags: 52
@ -309,7 +309,7 @@ MonoBehaviour:
m_SaveData: []
m_LockTracker:
m_IsLocked: 0
m_LastSelectedObjectID: 23628
m_LastSelectedObjectID: -2568
--- !u!114 &13
MonoBehaviour:
m_ObjectHideFlags: 52
@ -341,6 +341,7 @@ MonoBehaviour:
m_ViewTransforms:
m_KeySerializationHelper:
- {fileID: -1792117255979822615, guid: 7a9b8bdda3a418a408d0c8c2aa1ba937, type: 2}
- {fileID: -3884682661882762159, guid: bd5389f2f4813774ab1844173ff37005, type: 2}
m_ValueSerializationHelper:
- e00: 0.63028723
e01: 0
@ -358,10 +359,26 @@ MonoBehaviour:
e31: 0
e32: 0
e33: 1
- e00: 1
e01: 0
e02: 0
e03: 0
e10: 0
e11: 1
e12: 0
e13: 0
e20: 0
e21: 0
e22: 1
e23: 0
e30: 0
e31: 0
e32: 0
e33: 1
m_PreviewAnimator: {fileID: 0}
m_AnimatorController: {fileID: 9100000, guid: 7a9b8bdda3a418a408d0c8c2aa1ba937, type: 2}
m_AnimatorController: {fileID: 9100000, guid: bd5389f2f4813774ab1844173ff37005, type: 2}
m_BreadCrumbs:
- m_Target: {fileID: -1792117255979822615, guid: 7a9b8bdda3a418a408d0c8c2aa1ba937, type: 2}
- m_Target: {fileID: -3884682661882762159, guid: bd5389f2f4813774ab1844173ff37005, type: 2}
m_ScrollPosition: {x: 0, y: 0}
stateMachineGraph: {fileID: 0}
stateMachineGraphGUI: {fileID: 0}
@ -596,7 +613,7 @@ MonoBehaviour:
m_HSlider: 0
m_VSlider: 0
m_IgnoreScrollWheelUntilClicked: 0
m_EnableMouseInput: 0
m_EnableMouseInput: 1
m_EnableSliderZoomHorizontal: 0
m_EnableSliderZoomVertical: 0
m_UniformScale: 1
@ -660,8 +677,8 @@ MonoBehaviour:
floating: 0
collapsed: 0
displayed: 1
snapOffset: {x: -100, y: -25.599976}
snapOffsetDelta: {x: 0, y: 0}
snapOffset: {x: 0, y: 0}
snapOffsetDelta: {x: -100, y: -25.599976}
snapCorner: 3
id: Tool Settings
index: 0
@ -682,7 +699,7 @@ MonoBehaviour:
floating: 0
collapsed: 0
displayed: 1
snapOffset: {x: 0, y: 24.8}
snapOffset: {x: 0, y: 0}
snapOffsetDelta: {x: 0, y: 0}
snapCorner: 0
id: unity-scene-view-toolbar
@ -874,9 +891,9 @@ MonoBehaviour:
m_PlayAudio: 0
m_AudioPlay: 0
m_Position:
m_Target: {x: -8.067862, y: 2.1230044, z: 2.622212}
m_Target: {x: 1.628806, y: -1.5348046, z: -0.0052452465}
speed: 2
m_Value: {x: -7.674555, y: 2.0501382, z: 2.6335466}
m_Value: {x: 1.628806, y: -1.5348046, z: -0.0052452465}
m_RenderMode: 0
m_CameraMode:
drawMode: 0
@ -927,9 +944,9 @@ MonoBehaviour:
speed: 2
m_Value: {x: 0, y: 0, z: 0, w: 1}
m_Size:
m_Target: 26.321753
m_Target: 1.1425422
speed: 2
m_Value: 25.18828
m_Value: 1.1425422
m_Ortho:
m_Target: 1
speed: 2
@ -987,21 +1004,21 @@ MonoBehaviour:
scrollPos: {x: 0, y: 0}
m_SelectedIDs:
m_LastClickedID: 0
m_ExpandedIDs: 06fbffffa25b00004c5c0000
m_ExpandedIDs: 04fbffff
m_RenameOverlay:
m_UserAcceptedRename: 0
m_Name: Grid
m_OriginalName: Grid
m_Name:
m_OriginalName:
m_EditFieldRect:
serializedVersion: 2
x: 0
y: 0
width: 0
height: 0
m_UserData: 23458
m_UserData: 0
m_IsWaitingForDelay: 0
m_IsRenaming: 0
m_OriginalEventType: 0
m_OriginalEventType: 11
m_IsRenamingFilename: 0
m_ClientGUIView: {fileID: 9}
m_SearchString:
@ -1065,9 +1082,9 @@ MonoBehaviour:
m_IsLocked: 0
m_FolderTreeState:
scrollPos: {x: 0, y: 0}
m_SelectedIDs: 64910000
m_LastClickedID: 37220
m_ExpandedIDs: 00000000f85c0000c05e000000ca9a3b
m_SelectedIDs: f65e0000
m_LastClickedID: 24310
m_ExpandedIDs: 00000000485d0000005f000000ca9a3b
m_RenameOverlay:
m_UserAcceptedRename: 0
m_Name:
@ -1095,7 +1112,7 @@ MonoBehaviour:
scrollPos: {x: 0, y: 0}
m_SelectedIDs:
m_LastClickedID: 0
m_ExpandedIDs: 00000000f85c0000
m_ExpandedIDs: 00000000485d0000
m_RenameOverlay:
m_UserAcceptedRename: 0
m_Name:
@ -1123,7 +1140,7 @@ MonoBehaviour:
m_SelectedInstanceIDs:
m_LastClickedInstanceID: 0
m_HadKeyboardFocusLastEvent: 1
m_ExpandedInstanceIDs: c6230000
m_ExpandedInstanceIDs: c623000044610000
m_RenameOverlay:
m_UserAcceptedRename: 0
m_Name: