Commit f6c075ce authored by abpo11's avatar abpo11

가시 구현 완료. 넉백 거리와 데미지 수정 가능. ground layer에 spike 임시로 추가함.

모든 spike에 콜라이더 추가 필요
parent f035a364
...@@ -123,6 +123,9 @@ GameObject: ...@@ -123,6 +123,9 @@ GameObject:
- component: {fileID: 4202914257283556} - component: {fileID: 4202914257283556}
- component: {fileID: 8195094281688291738} - component: {fileID: 8195094281688291738}
- component: {fileID: 3664157344750859314} - component: {fileID: 3664157344750859314}
- component: {fileID: 2113883504719364560}
- component: {fileID: 50510369170615966}
- component: {fileID: 66891075305192572}
m_Layer: 10 m_Layer: 10
m_Name: spike m_Name: spike
m_TagString: Untagged m_TagString: Untagged
...@@ -341,6 +344,26 @@ Rigidbody2D: ...@@ -341,6 +344,26 @@ Rigidbody2D:
m_SleepingMode: 1 m_SleepingMode: 1
m_CollisionDetection: 0 m_CollisionDetection: 0
m_Constraints: 0 m_Constraints: 0
--- !u!50 &50510369170615966
Rigidbody2D:
serializedVersion: 4
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1687661689682920}
m_BodyType: 2
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: 0}
m_Interpolate: 0
m_SleepingMode: 1
m_CollisionDetection: 0
m_Constraints: 0
--- !u!50 &50664629928502538 --- !u!50 &50664629928502538
Rigidbody2D: Rigidbody2D:
serializedVersion: 4 serializedVersion: 4
...@@ -849,6 +872,26 @@ CompositeCollider2D: ...@@ -849,6 +872,26 @@ CompositeCollider2D:
- {x: 0, y: 0} - {x: 0, y: 0}
- {x: 11, y: 0} - {x: 11, y: 0}
m_VertexDistance: 0.0005 m_VertexDistance: 0.0005
--- !u!66 &66891075305192572
CompositeCollider2D:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1687661689682920}
m_Enabled: 1
m_Density: 1
m_Material: {fileID: 0}
m_IsTrigger: 0
m_UsedByEffector: 0
m_UsedByComposite: 0
m_Offset: {x: 0, y: 0}
m_GeometryType: 0
m_GenerationType: 0
m_EdgeRadius: 0
m_ColliderPaths: []
m_CompositePaths:
m_Paths: []
m_VertexDistance: 0.0005
--- !u!114 &114127645492151898 --- !u!114 &114127645492151898
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 1 m_ObjectHideFlags: 1
...@@ -953,6 +996,19 @@ TilemapCollider2D: ...@@ -953,6 +996,19 @@ TilemapCollider2D:
m_UsedByEffector: 0 m_UsedByEffector: 0
m_UsedByComposite: 1 m_UsedByComposite: 1
m_Offset: {x: 0, y: 0} m_Offset: {x: 0, y: 0}
--- !u!19719996 &2113883504719364560
TilemapCollider2D:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1687661689682920}
m_Enabled: 1
m_Density: 1
m_Material: {fileID: 0}
m_IsTrigger: 0
m_UsedByEffector: 0
m_UsedByComposite: 1
m_Offset: {x: 0, y: 0}
--- !u!19719996 &2113883505917435124 --- !u!19719996 &2113883505917435124
TilemapCollider2D: TilemapCollider2D:
m_ObjectHideFlags: 1 m_ObjectHideFlags: 1
......
...@@ -34,7 +34,7 @@ Transform: ...@@ -34,7 +34,7 @@ Transform:
m_PrefabInternal: {fileID: 100100000} m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1704656476422024} m_GameObject: {fileID: 1704656476422024}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 192, y: 0, z: -2} m_LocalPosition: {x: 72, y: 0, z: -2}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: [] m_Children: []
m_Father: {fileID: 0} m_Father: {fileID: 0}
......
...@@ -404,6 +404,27 @@ GameObject: ...@@ -404,6 +404,27 @@ GameObject:
m_CorrespondingSourceObject: {fileID: 1623439448163086, guid: 3d077a5f727dd1e4780e9265ed26e036, m_CorrespondingSourceObject: {fileID: 1623439448163086, guid: 3d077a5f727dd1e4780e9265ed26e036,
type: 2} type: 2}
m_PrefabInternal: {fileID: 1618052740} m_PrefabInternal: {fileID: 1618052740}
--- !u!114 &489222434
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 489222433}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: a4458b2b5e7c3f842b29e2121f8400ea, type: 3}
m_Name:
m_EditorClassIdentifier:
spikeTile:
- {fileID: 11400000, guid: 7f2c5cb43ad7207499b22fb5e0acd41a, type: 2}
- {fileID: 11400000, guid: f411e29431b787c4ab84b5ff59ca5e6e, type: 2}
- {fileID: 11400000, guid: 85440e0dd81e48840947ce485614bab6, type: 2}
- {fileID: 11400000, guid: 7dbb7c55a3417f54fbd38fafb369478e, type: 2}
rb: {fileID: 0}
SpikeLayer: 10
spikeDamage: 5
spikeKnockBackx: 10
spikeKnockBacky: 10
--- !u!223 &647962947 stripped --- !u!223 &647962947 stripped
Canvas: Canvas:
m_CorrespondingSourceObject: {fileID: 223237664237935382, guid: 692aad2449e06054799ea4706578fb23, m_CorrespondingSourceObject: {fileID: 223237664237935382, guid: 692aad2449e06054799ea4706578fb23,
...@@ -1541,6 +1562,11 @@ Prefab: ...@@ -1541,6 +1562,11 @@ Prefab:
propertyPath: m_Enabled propertyPath: m_Enabled
value: 1 value: 1
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 114294925164316638, guid: 3d077a5f727dd1e4780e9265ed26e036,
type: 2}
propertyPath: groundLayer.m_Bits
value: 7424
objectReference: {fileID: 0}
m_RemovedComponents: [] m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 3d077a5f727dd1e4780e9265ed26e036, type: 2} m_SourcePrefab: {fileID: 100100000, guid: 3d077a5f727dd1e4780e9265ed26e036, type: 2}
m_IsPrefabAsset: 0 m_IsPrefabAsset: 0
...@@ -1813,6 +1839,11 @@ Prefab: ...@@ -1813,6 +1839,11 @@ Prefab:
propertyPath: m_CullingMask.m_Bits propertyPath: m_CullingMask.m_Bits
value: 4294967295 value: 4294967295
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 81874366432473632, guid: b67c2e6425443f14c85899a92710bf3f,
type: 2}
propertyPath: m_Enabled
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: [] m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: b67c2e6425443f14c85899a92710bf3f, type: 2} m_SourcePrefab: {fileID: 100100000, guid: b67c2e6425443f14c85899a92710bf3f, type: 2}
m_IsPrefabAsset: 0 m_IsPrefabAsset: 0
......
...@@ -67,12 +67,12 @@ public class Enemy : MonoBehaviour { ...@@ -67,12 +67,12 @@ public class Enemy : MonoBehaviour {
bool wallTest = IsTouchingWall(); bool wallTest = IsTouchingWall();
if (wallTest) if (wallTest)
{ {
Debug.Log("Touching wall"); // Debug.Log("Touching wall");
} }
bool cliffTest = IsAdvancingToCliff(); bool cliffTest = IsAdvancingToCliff();
if (cliffTest) if (cliffTest)
{ {
Debug.Log("Advancing to cliff"); // Debug.Log("Advancing to cliff");
} }
} }
......
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Tilemaps;
public class playerOnSpike : MonoBehaviour {
public TileBase[] spikeTile;
public Rigidbody2D rb;
public int SpikeLayer = 10; //10 is for spike layer
public float spikeDamage = 5f;
public float spikeKnockBackx = 5f;
public float spikeKnockBacky = 5f;
private void Start()
{
rb = GetComponent<Rigidbody2D>();
}
void OnCollisionEnter2D(Collision2D coll)
{
if (coll.gameObject.layer == SpikeLayer)
{
Tilemap t = coll.gameObject.GetComponent<Tilemap>();
Vector3 hitPosition = Vector3.zero;
ContactPoint2D hit = coll.contacts[0];
hitPosition.x = hit.point.x - 0.01f * hit.normal.x;
hitPosition.y = hit.point.y - 0.01f * hit.normal.y;
//충돌 위치 중심 계산
TileBase colTile = t.GetTile(t.WorldToCell(hitPosition));
if (colTile != null)
{
EnemyAttackInfo attack = new EnemyAttackInfo(spikeDamage, 0f, 0, null, null); //넉백은 따로 구현
GetComponent<PlayerAttack>().TakeDamage(attack);
//방향에 따른 넉백 구현
if (colTile == spikeTile[0]) //spike up tile
{
// print("uuch!");
rb.velocity = new Vector2(rb.velocity.x, spikeKnockBacky);
}
else if (colTile == spikeTile[1]) //spike down tile
{
// print("duch!");
rb.velocity = new Vector2(rb.velocity.x, -spikeKnockBacky);
}
if (colTile == spikeTile[2]) //spike l tile
{
// print("luch!");
rb.velocity = new Vector2( -spikeKnockBackx, rb.velocity.y);
}
else if (colTile == spikeTile[3]) //spike r tile
{
// print("ruch!");
rb.velocity = new Vector2( spikeKnockBackx, rb.velocity.y);
}
}
}
}
}
fileFormatVersion: 2
guid: a4458b2b5e7c3f842b29e2121f8400ea
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class tiletest : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
}
fileFormatVersion: 2
guid: eb17c0dc633a1ef4c8337e5ffa1ffdae
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment