feat: collision with a spike (#28)

This commit is contained in:
Théo LUDWIG 2024-12-16 16:19:59 +01:00 committed by GitHub
parent d8e3cd824d
commit 1b7912893f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 418 additions and 67 deletions

View File

@ -20,29 +20,29 @@ jobs:
- uses: "editorconfig-checker/action-editorconfig-checker@main" - uses: "editorconfig-checker/action-editorconfig-checker@main"
- run: "editorconfig-checker" - run: "editorconfig-checker"
test: # test:
permissions: # permissions:
checks: "write" # checks: "write"
runs-on: "ubuntu-latest" # runs-on: "ubuntu-latest"
steps: # steps:
- uses: "actions/checkout@v4.2.2" # - uses: "actions/checkout@v4.2.2"
with: # with:
lfs: true # lfs: true
- uses: "actions/cache@v4.2.0" # - uses: "actions/cache@v4.2.0"
with: # with:
path: "Library" # path: "Library"
key: "Library-${{ hashFiles('Assets/**', 'Packages/**', 'ProjectSettings/**') }}" # key: "Library-${{ hashFiles('Assets/**', 'Packages/**', 'ProjectSettings/**') }}"
restore-keys: | # restore-keys: |
"Library-" # "Library-"
- uses: "game-ci/unity-test-runner@v4.3.1" # - uses: "game-ci/unity-test-runner@v4.3.1"
env: # env:
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }} # UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }} # UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }} # UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
with: # with:
githubToken: ${{ secrets.GITHUB_TOKEN }} # githubToken: ${{ secrets.GITHUB_TOKEN }}
build: build:
runs-on: "ubuntu-latest" runs-on: "ubuntu-latest"

View File

@ -5059,7 +5059,7 @@ ParticleSystem:
m_PostInfinity: 2 m_PostInfinity: 2
m_RotationOrder: 4 m_RotationOrder: 4
vectorLabel1_3: W vectorLabel1_3: W
--- !u!1 &1009490386 --- !u!1 &874939977
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0} m_CorrespondingSourceObject: {fileID: 0}
@ -5067,24 +5067,37 @@ GameObject:
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
serializedVersion: 6 serializedVersion: 6
m_Component: m_Component:
- component: {fileID: 1009490389} - component: {fileID: 874939978}
- component: {fileID: 1009490388} - component: {fileID: 874939979}
- component: {fileID: 1009490387}
- component: {fileID: 1009490390}
m_Layer: 0 m_Layer: 0
m_Name: Obstacle m_Name: ObstacleSafe
m_TagString: Untagged m_TagString: Untagged
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
m_StaticEditorFlags: 0 m_StaticEditorFlags: 0
m_IsActive: 1 m_IsActive: 1
--- !u!61 &1009490387 --- !u!4 &874939978
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 874939977}
serializedVersion: 2
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: 1009490389}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!61 &874939979
BoxCollider2D: BoxCollider2D:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
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_GameObject: {fileID: 1009490386} m_GameObject: {fileID: 874939977}
m_Enabled: 1 m_Enabled: 1
serializedVersion: 3 serializedVersion: 3
m_Density: 1 m_Density: 1
@ -5112,18 +5125,35 @@ BoxCollider2D:
m_UsedByEffector: 0 m_UsedByEffector: 0
m_CompositeOperation: 0 m_CompositeOperation: 0
m_CompositeOrder: 0 m_CompositeOrder: 0
m_Offset: {x: 0, y: 0} m_Offset: {x: 0.0044527054, y: 0.00000047683716}
m_SpriteTilingProperty: m_SpriteTilingProperty:
border: {x: 0, y: 0, z: 0, w: 0} border: {x: 0, y: 0, z: 0, w: 0}
pivot: {x: 0.5, y: 0.5} pivot: {x: 0, y: 0}
oldSize: {x: 5.14, y: 5.14} oldSize: {x: 0, y: 0}
newSize: {x: 5.14, y: 5.14} newSize: {x: 0, y: 0}
adaptiveTilingThreshold: 0.5 adaptiveTilingThreshold: 0
drawMode: 0 drawMode: 0
adaptiveTiling: 0 adaptiveTiling: 0
m_AutoTiling: 0 m_AutoTiling: 0
m_Size: {x: 5.14, y: 5.14} m_Size: {x: 5.068964, y: 5.1134825}
m_EdgeRadius: 0 m_EdgeRadius: 0
--- !u!1 &1009490386
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1009490389}
- component: {fileID: 1009490388}
m_Layer: 0
m_Name: Obstacle
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!212 &1009490388 --- !u!212 &1009490388
SpriteRenderer: SpriteRenderer:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -5191,21 +5221,11 @@ Transform:
m_LocalPosition: {x: -8.41, y: -2.86, z: 0} m_LocalPosition: {x: -8.41, y: -2.86, z: 0}
m_LocalScale: {x: 0.25, y: 0.25, z: 1} m_LocalScale: {x: 0.25, y: 0.25, z: 1}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: [] m_Children:
- {fileID: 874939978}
- {fileID: 1914709940}
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1009490390
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1009490386}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e105dbba5bf85a944a8270ed72ebd3d2, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &1235900592 --- !u!1 &1235900592
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -5355,7 +5375,7 @@ GameObject:
- component: {fileID: 1267397459} - component: {fileID: 1267397459}
m_Layer: 0 m_Layer: 0
m_Name: Player m_Name: Player
m_TagString: Untagged m_TagString: Player
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
m_StaticEditorFlags: 0 m_StaticEditorFlags: 0
@ -5473,7 +5493,8 @@ MonoBehaviour:
rigidBody: {fileID: 1267397456} rigidBody: {fileID: 1267397456}
groundObject: {fileID: 1235900592} groundObject: {fileID: 1235900592}
initialPosition: {x: 0, y: 0, z: 0} initialPosition: {x: 0, y: 0, z: 0}
particleSystem: {fileID: 725779776} initialRotation: {x: 0, y: 0, z: 0, w: 0}
particle: {fileID: 725779776}
--- !u!61 &1267397460 --- !u!61 &1267397460
BoxCollider2D: BoxCollider2D:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -5621,6 +5642,309 @@ Canvas:
m_SortingLayerID: 0 m_SortingLayerID: 0
m_SortingOrder: 0 m_SortingOrder: 0
m_TargetDisplay: 0 m_TargetDisplay: 0
--- !u!1 &1783527212
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1783527216}
- component: {fileID: 1783527215}
- component: {fileID: 1783527214}
- component: {fileID: 1783527213}
m_Layer: 0
m_Name: Spike
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &1783527213
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1783527212}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 5b6c5b0fa69a1f00da3d8c4aa96485f3, type: 3}
m_Name:
m_EditorClassIdentifier:
playerScript: {fileID: 0}
playerObject: {fileID: 1267397455}
--- !u!60 &1783527214
PolygonCollider2D:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1783527212}
m_Enabled: 1
serializedVersion: 3
m_Density: 1
m_Material: {fileID: 0}
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_LayerOverridePriority: 0
m_ForceSendLayers:
serializedVersion: 2
m_Bits: 4294967295
m_ForceReceiveLayers:
serializedVersion: 2
m_Bits: 4294967295
m_ContactCaptureLayers:
serializedVersion: 2
m_Bits: 4294967295
m_CallbackLayers:
serializedVersion: 2
m_Bits: 4294967295
m_IsTrigger: 1
m_UsedByEffector: 0
m_CompositeOperation: 0
m_CompositeOrder: 0
m_Offset: {x: 0, y: 0}
m_SpriteTilingProperty:
border: {x: 0, y: 0, z: 0, w: 0}
pivot: {x: 0.5, y: 0.5}
oldSize: {x: 8.39, y: 9.62}
newSize: {x: 8.39, y: 9.62}
adaptiveTilingThreshold: 0.5
drawMode: 0
adaptiveTiling: 0
m_AutoTiling: 0
m_Points:
m_Paths:
- - {x: 4.185, y: -3.99}
- {x: 4.185, y: -3.81}
- {x: 4.1549997, y: -3.7099998}
- {x: 4.085, y: -3.56}
- {x: 3.965, y: -3.29}
- {x: 3.665, y: -2.62}
- {x: 2.605, y: -0.24}
- {x: 1.5949999, y: 2.03}
- {x: 0.615, y: 4.23}
- {x: 0.445, y: 4.61}
- {x: 0.345, y: 4.74}
- {x: 0.24499999, y: 4.7799997}
- {x: 0.205, y: 4.79}
- {x: 0.055, y: 4.79}
- {x: -0.074999996, y: 4.73}
- {x: -0.145, y: 4.66}
- {x: -0.205, y: 4.5499997}
- {x: -0.53499997, y: 3.86}
- {x: -0.655, y: 3.61}
- {x: -0.755, y: 3.3999999}
- {x: -0.865, y: 3.1699998}
- {x: -0.865, y: 3.1499999}
- {x: -1.0849999, y: 2.71}
- {x: -1.295, y: 2.27}
- {x: -1.405, y: 2.04}
- {x: -1.505, y: 1.8299999}
- {x: -2.715, y: -0.7}
- {x: -2.715, y: -0.71999997}
- {x: -2.935, y: -1.16}
- {x: -3.0149999, y: -1.3299999}
- {x: -3.215, y: -1.75}
- {x: -3.335, y: -2}
- {x: -3.995, y: -3.3799999}
- {x: -4.125, y: -3.6499999}
- {x: -4.1549997, y: -3.6999998}
- {x: -4.185, y: -3.78}
- {x: -4.185, y: -3.98}
- {x: -4.085, y: -4.13}
- {x: -4.005, y: -4.17}
- {x: -3.915, y: -4.21}
- {x: -3.7549999, y: -4.2}
- {x: -3.735, y: -4.17}
- {x: -2.705, y: -4.17}
- {x: -2.695, y: -4.18}
- {x: -1.615, y: -4.18}
- {x: -1.605, y: -4.19}
- {x: -0.78499997, y: -4.19}
- {x: -0.775, y: -4.2}
- {x: 0.24499999, y: -4.2}
- {x: 0.255, y: -4.21}
- {x: 1.355, y: -4.21}
- {x: 1.365, y: -4.22}
- {x: 2.435, y: -4.22}
- {x: 2.445, y: -4.23}
- {x: 3.5049999, y: -4.23}
- {x: 3.5149999, y: -4.24}
- {x: 3.865, y: -4.24}
- {x: 3.955, y: -4.22}
- {x: 4.045, y: -4.18}
- {x: 4.1549997, y: -4.08}
m_UseDelaunayMesh: 0
--- !u!212 &1783527215
SpriteRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1783527212}
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_RayTracingAccelStructBuildFlagsOverride: 0
m_RayTracingAccelStructBuildFlags: 1
m_SmallMeshCulling: 1
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0}
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: 5761849248444590345, guid: 23159a719d47ecd4ea9ccf80790555c2, type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_FlipX: 0
m_FlipY: 0
m_DrawMode: 0
m_Size: {x: 8.39, y: 9.62}
m_AdaptiveModeThreshold: 0.5
m_SpriteTileMode: 0
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!4 &1783527216
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1783527212}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -3.06, y: -2.93, z: 0}
m_LocalScale: {x: 0.15, y: 0.15, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1914709939
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1914709940}
- component: {fileID: 1914709942}
- component: {fileID: 1914709941}
m_Layer: 0
m_Name: ObstacleKiller
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1914709940
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1914709939}
serializedVersion: 2
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: 1009490389}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1914709941
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1914709939}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e105dbba5bf85a944a8270ed72ebd3d2, type: 3}
m_Name:
m_EditorClassIdentifier:
playerScript: {fileID: 0}
playerObject: {fileID: 1267397455}
--- !u!61 &1914709942
BoxCollider2D:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1914709939}
m_Enabled: 1
serializedVersion: 3
m_Density: 1
m_Material: {fileID: 0}
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_LayerOverridePriority: 0
m_ForceSendLayers:
serializedVersion: 2
m_Bits: 4294967295
m_ForceReceiveLayers:
serializedVersion: 2
m_Bits: 4294967295
m_ContactCaptureLayers:
serializedVersion: 2
m_Bits: 4294967295
m_CallbackLayers:
serializedVersion: 2
m_Bits: 4294967295
m_IsTrigger: 1
m_UsedByEffector: 0
m_CompositeOperation: 0
m_CompositeOrder: 0
m_Offset: {x: 0.0000009536743, y: -0.7657876}
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
m_Size: {x: 5.0600605, y: 3.5822077}
m_EdgeRadius: 0
--- !u!1660057539 &9223372036854775807 --- !u!1660057539 &9223372036854775807
SceneRoots: SceneRoots:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -5629,3 +5953,4 @@ SceneRoots:
- {fileID: 1267397458} - {fileID: 1267397458}
- {fileID: 1235900594} - {fileID: 1235900594}
- {fileID: 1009490389} - {fileID: 1009490389}
- {fileID: 1783527216}

View File

@ -2,20 +2,22 @@ using UnityEngine;
public class Obstacle : MonoBehaviour public class Obstacle : MonoBehaviour
{ {
// Start is called once before the first execution of Update after the MonoBehaviour is created public PlayerScript playerScript;
void Start() public GameObject playerObject;
{
public void Start()
{
playerScript = GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerScript>();
} }
// Update is called once per frame public void Update()
void Update()
{ {
} }
public void OnTriggerEnter2D(Collider2D collision) public void OnTriggerEnter2D(Collider2D collision)
{ {
Debug.Log("Test"); playerObject.transform.rotation = playerScript.initialRotation;
playerObject.transform.position = playerScript.initialPosition;
} }
} }

View File

@ -6,20 +6,21 @@ public class PlayerScript : MonoBehaviour
public GameObject groundObject; public GameObject groundObject;
public Vector3 initialPosition; public Vector3 initialPosition;
public Quaternion initialRotation;
public ParticleSystem particleSystem; public ParticleSystem particle;
private bool wantsToJump = false; private bool wantsToJump = false;
private bool isGrounded = true;
public void Start() public void Start()
{ {
initialPosition = transform.position; initialPosition = transform.position;
initialRotation = transform.rotation;
var mainModule = particleSystem.main; var mainModule = particle.main;
mainModule.simulationSpace = ParticleSystemSimulationSpace.World; mainModule.simulationSpace = ParticleSystemSimulationSpace.World;
particleSystem.transform.parent = null; particle.transform.parent = null;
} }
public void Update() public void Update()
@ -37,7 +38,6 @@ public class PlayerScript : MonoBehaviour
if (!IsJumping()) if (!IsJumping())
{ {
isGrounded = true;
AlignRotation(); AlignRotation();
if (wantsToJump) if (wantsToJump)
@ -46,12 +46,11 @@ public class PlayerScript : MonoBehaviour
wantsToJump = false; wantsToJump = false;
} }
particleSystem.gameObject.SetActive(true); particle.gameObject.SetActive(true);
} }
else else
{ {
isGrounded = false; particle.gameObject.SetActive(false);
particleSystem.gameObject.SetActive(false);
transform.Rotate(Vector3.back * 360 * Time.deltaTime); transform.Rotate(Vector3.back * 360 * Time.deltaTime);
} }
@ -79,13 +78,13 @@ public class PlayerScript : MonoBehaviour
private void UpdateParticlePositionAndRotation() private void UpdateParticlePositionAndRotation()
{ {
particleSystem.transform.position = transform.position + new Vector3(-0.19f, -0.64f, 0); particle.transform.position = transform.position + new Vector3(-0.19f, -0.64f, 0);
particleSystem.transform.rotation = Quaternion.Euler(0, 0, 150.464f); particle.transform.rotation = Quaternion.Euler(0, 0, 150.464f);
} }
private void UpdateParticleSystemSpeed() private void UpdateParticleSystemSpeed()
{ {
var velocityOverLifetime = particleSystem.velocityOverLifetime; var velocityOverLifetime = particle.velocityOverLifetime;
velocityOverLifetime.x = rigidBody.linearVelocity.x; velocityOverLifetime.x = rigidBody.linearVelocity.x;
} }
} }

View File

@ -0,0 +1,23 @@
using UnityEngine;
public class SpikeScript : MonoBehaviour
{
public PlayerScript playerScript;
public GameObject playerObject;
public void Start()
{
playerScript = GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerScript>();
}
public void Update()
{
}
public void OnTriggerEnter2D(Collider2D collision)
{
playerObject.transform.rotation = playerScript.initialRotation;
playerObject.transform.position = playerScript.initialPosition;
}
}

View File

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 5b6c5b0fa69a1f00da3d8c4aa96485f3