Destroyable tile blocks with TilesExtra
still issues with collider
This commit is contained in:
@@ -0,0 +1,178 @@
|
|||||||
|
%YAML 1.1
|
||||||
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!1 &6742600071965714980
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 7515349249133635430}
|
||||||
|
- component: {fileID: 1557174451233602412}
|
||||||
|
m_Layer: 0
|
||||||
|
m_Name: Visual
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!4 &7515349249133635430
|
||||||
|
Transform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 6742600071965714980}
|
||||||
|
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: 7345322822309755345}
|
||||||
|
m_RootOrder: -1
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
--- !u!212 &1557174451233602412
|
||||||
|
SpriteRenderer:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 6742600071965714980}
|
||||||
|
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: -133646357
|
||||||
|
m_SortingLayer: 2
|
||||||
|
m_SortingOrder: 0
|
||||||
|
m_Sprite: {fileID: -1109035998, guid: 7c2d6acd22d2d0c40b84d99967afb42a, type: 3}
|
||||||
|
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||||
|
m_FlipX: 0
|
||||||
|
m_FlipY: 0
|
||||||
|
m_DrawMode: 0
|
||||||
|
m_Size: {x: 1.0230769, y: 1.0076923}
|
||||||
|
m_AdaptiveModeThreshold: 0.5
|
||||||
|
m_SpriteTileMode: 0
|
||||||
|
m_WasSpriteAssigned: 1
|
||||||
|
m_MaskInteraction: 0
|
||||||
|
m_SpriteSortPoint: 0
|
||||||
|
--- !u!1 &8175732239415438715
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 7345322822309755345}
|
||||||
|
- component: {fileID: 3364452304498334467}
|
||||||
|
- component: {fileID: -1797789796822257734}
|
||||||
|
m_Layer: 0
|
||||||
|
m_Name: BreakableTile
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!4 &7345322822309755345
|
||||||
|
Transform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 8175732239415438715}
|
||||||
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
|
m_LocalPosition: {x: -2.4775906, y: -4.069116, z: 0.16478391}
|
||||||
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
|
m_ConstrainProportionsScale: 0
|
||||||
|
m_Children:
|
||||||
|
- {fileID: 7515349249133635430}
|
||||||
|
m_Father: {fileID: 0}
|
||||||
|
m_RootOrder: 6
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
--- !u!61 &3364452304498334467
|
||||||
|
BoxCollider2D:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 8175732239415438715}
|
||||||
|
m_Enabled: 1
|
||||||
|
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: 0
|
||||||
|
m_UsedByEffector: 0
|
||||||
|
m_UsedByComposite: 0
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
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: 1, y: 1}
|
||||||
|
m_EdgeRadius: 0
|
||||||
|
--- !u!114 &-1797789796822257734
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 8175732239415438715}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: edf40d39eadb17a4ebb0368b3ac5399a, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
_elementSO: {fileID: 11400000, guid: da0ec95da6f0526499978941b1631c3e, type: 2}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 3d1aa56cd139405448c73b1385177b04
|
||||||
|
PrefabImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
+1514
-40
File diff suppressed because it is too large
Load Diff
@@ -36,7 +36,7 @@ public class Character : MonoBehaviour
|
|||||||
_isOnBridge = mapElement == MapElementType.Bridge && !_isFalling;
|
_isOnBridge = mapElement == MapElementType.Bridge && !_isFalling;
|
||||||
|
|
||||||
float v_movement=0;
|
float v_movement=0;
|
||||||
if (mapElement==MapElementType.Wall || _isOnLadder || _isOnBridge)
|
if (mapElement==MapElementType.Wall || _isOnLadder || _isOnBridge|| mapElement == MapElementType.BreakableWall)
|
||||||
{
|
{
|
||||||
var leftCheck = GetMapElement(Vector2.left);
|
var leftCheck = GetMapElement(Vector2.left);
|
||||||
var rightCheck = GetMapElement(Vector2.right);
|
var rightCheck = GetMapElement(Vector2.right);
|
||||||
@@ -93,7 +93,7 @@ public class Character : MonoBehaviour
|
|||||||
|
|
||||||
private MapElementType GetMapElement(Vector2 direction)
|
private MapElementType GetMapElement(Vector2 direction)
|
||||||
{
|
{
|
||||||
var raycastHit=Physics2D.BoxCast(_boxCollider.bounds.center, _boxCollider.bounds.size, 0f, direction, .1f, _mapLayer);
|
var raycastHit=Physics2D.BoxCast(_boxCollider.bounds.center, _boxCollider.bounds.size, 0f, direction, 0.1f, _mapLayer);
|
||||||
if (raycastHit)
|
if (raycastHit)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@@ -12,10 +12,12 @@ public class Hammer : MonoBehaviour
|
|||||||
|
|
||||||
private void OnCollisionEnter2D(Collision2D collision)
|
private void OnCollisionEnter2D(Collision2D collision)
|
||||||
{
|
{
|
||||||
var player = collision.collider.GetComponent<Player>();
|
var mapElement = collision.collider.GetComponent<MapElement>();
|
||||||
if (player == null)
|
if (mapElement?.ElementSO.ElementType==MapElementType.BreakableWall)
|
||||||
{
|
{
|
||||||
|
Destroy(collision.gameObject);
|
||||||
Destroy(gameObject);
|
Destroy(gameObject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -12,4 +12,4 @@ MonoBehaviour:
|
|||||||
m_Script: {fileID: 11500000, guid: 541209b3a8828a3429d3a6c93b0350f3, type: 3}
|
m_Script: {fileID: 11500000, guid: 541209b3a8828a3429d3a6c93b0350f3, type: 3}
|
||||||
m_Name: BreakableWall
|
m_Name: BreakableWall
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
ElementType: 0
|
ElementType: 4
|
||||||
|
|||||||
@@ -1,8 +1,32 @@
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
public class MapElement:MonoBehaviour
|
public class MapElement : MonoBehaviour
|
||||||
{
|
{
|
||||||
[SerializeField]
|
[SerializeField]
|
||||||
private MapElementSO _elementSO;
|
private MapElementSO _elementSO;
|
||||||
public MapElementSO ElementSO => _elementSO;
|
public MapElementSO ElementSO => _elementSO;
|
||||||
|
|
||||||
|
private float _respawnElementTimer;
|
||||||
|
private int _respawnTimeout = 4;
|
||||||
|
private bool _needRespawn = false;
|
||||||
|
public void Hit()
|
||||||
|
{
|
||||||
|
gameObject.GetComponent<BoxCollider2D>().enabled = false;
|
||||||
|
_needRespawn = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Update()
|
||||||
|
{
|
||||||
|
if (_needRespawn)
|
||||||
|
{
|
||||||
|
_respawnElementTimer -= Time.deltaTime;
|
||||||
|
if (_respawnElementTimer <= 0)
|
||||||
|
{
|
||||||
|
_respawnElementTimer = _respawnTimeout;
|
||||||
|
gameObject.GetComponent<BoxCollider2D>().enabled = true;
|
||||||
|
_needRespawn = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -6,6 +6,7 @@
|
|||||||
"com.unity.2d.sprite": "1.0.0",
|
"com.unity.2d.sprite": "1.0.0",
|
||||||
"com.unity.2d.spriteshape": "9.0.2",
|
"com.unity.2d.spriteshape": "9.0.2",
|
||||||
"com.unity.2d.tilemap": "1.0.0",
|
"com.unity.2d.tilemap": "1.0.0",
|
||||||
|
"com.unity.2d.tilemap.extras": "3.1.1",
|
||||||
"com.unity.ads": "4.4.2",
|
"com.unity.ads": "4.4.2",
|
||||||
"com.unity.ai.navigation": "1.1.3",
|
"com.unity.ai.navigation": "1.1.3",
|
||||||
"com.unity.analytics": "3.8.1",
|
"com.unity.analytics": "3.8.1",
|
||||||
|
|||||||
@@ -70,6 +70,18 @@
|
|||||||
"com.unity.modules.uielements": "1.0.0"
|
"com.unity.modules.uielements": "1.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"com.unity.2d.tilemap.extras": {
|
||||||
|
"version": "3.1.1",
|
||||||
|
"depth": 0,
|
||||||
|
"source": "registry",
|
||||||
|
"dependencies": {
|
||||||
|
"com.unity.modules.tilemap": "1.0.0",
|
||||||
|
"com.unity.2d.tilemap": "1.0.0",
|
||||||
|
"com.unity.ugui": "1.0.0",
|
||||||
|
"com.unity.modules.jsonserialize": "1.0.0"
|
||||||
|
},
|
||||||
|
"url": "https://packages.unity.com"
|
||||||
|
},
|
||||||
"com.unity.ads": {
|
"com.unity.ads": {
|
||||||
"version": "4.4.2",
|
"version": "4.4.2",
|
||||||
"depth": 0,
|
"depth": 0,
|
||||||
|
|||||||
Reference in New Issue
Block a user