Collision for bullet
This commit is contained in:
parent
6a2c9787e7
commit
788d87452d
2 changed files with 38 additions and 8 deletions
|
@ -19,9 +19,10 @@ GameObject:
|
||||||
serializedVersion: 5
|
serializedVersion: 5
|
||||||
m_Component:
|
m_Component:
|
||||||
- component: {fileID: 4781595464190240}
|
- component: {fileID: 4781595464190240}
|
||||||
- component: {fileID: 58664560518688016}
|
|
||||||
- component: {fileID: 212185122411066660}
|
- component: {fileID: 212185122411066660}
|
||||||
- component: {fileID: 114075590146335024}
|
- component: {fileID: 114075590146335024}
|
||||||
|
- component: {fileID: 61667207399653724}
|
||||||
|
- component: {fileID: 50031891945467640}
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: Bullet
|
m_Name: Bullet
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
|
@ -42,8 +43,28 @@ Transform:
|
||||||
m_Father: {fileID: 0}
|
m_Father: {fileID: 0}
|
||||||
m_RootOrder: 0
|
m_RootOrder: 0
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
--- !u!58 &58664560518688016
|
--- !u!50 &50031891945467640
|
||||||
CircleCollider2D:
|
Rigidbody2D:
|
||||||
|
serializedVersion: 4
|
||||||
|
m_ObjectHideFlags: 1
|
||||||
|
m_PrefabParentObject: {fileID: 0}
|
||||||
|
m_PrefabInternal: {fileID: 100100000}
|
||||||
|
m_GameObject: {fileID: 1379543051791382}
|
||||||
|
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: 0}
|
||||||
|
m_Interpolate: 0
|
||||||
|
m_SleepingMode: 1
|
||||||
|
m_CollisionDetection: 0
|
||||||
|
m_Constraints: 0
|
||||||
|
--- !u!61 &61667207399653724
|
||||||
|
BoxCollider2D:
|
||||||
m_ObjectHideFlags: 1
|
m_ObjectHideFlags: 1
|
||||||
m_PrefabParentObject: {fileID: 0}
|
m_PrefabParentObject: {fileID: 0}
|
||||||
m_PrefabInternal: {fileID: 100100000}
|
m_PrefabInternal: {fileID: 100100000}
|
||||||
|
@ -54,9 +75,19 @@ CircleCollider2D:
|
||||||
m_IsTrigger: 0
|
m_IsTrigger: 0
|
||||||
m_UsedByEffector: 0
|
m_UsedByEffector: 0
|
||||||
m_UsedByComposite: 0
|
m_UsedByComposite: 0
|
||||||
m_Offset: {x: -0.0030702911, y: 0.0782015}
|
m_Offset: {x: -0.0035692453, y: 0.022604823}
|
||||||
|
m_SpriteTilingProperty:
|
||||||
|
border: {x: 0, y: 0, z: 0, w: 0}
|
||||||
|
pivot: {x: 0.5, y: 0.5}
|
||||||
|
oldSize: {x: 1, y: 1}
|
||||||
|
newSize: {x: 10, y: 10}
|
||||||
|
adaptiveTilingThreshold: 0.5
|
||||||
|
drawMode: 0
|
||||||
|
adaptiveTiling: 0
|
||||||
|
m_AutoTiling: 0
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
m_Radius: 0.05788156
|
m_Size: {x: 0.12197816, y: 0.23143363}
|
||||||
|
m_EdgeRadius: 0
|
||||||
--- !u!114 &114075590146335024
|
--- !u!114 &114075590146335024
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
m_ObjectHideFlags: 1
|
m_ObjectHideFlags: 1
|
||||||
|
|
|
@ -26,15 +26,14 @@ public class Bullet : MonoBehaviour {
|
||||||
void Update () {
|
void Update () {
|
||||||
if ( owner == null )
|
if ( owner == null )
|
||||||
return;
|
return;
|
||||||
transform.position = transform.position + transform.localRotation * Vector3.up * speed * Time.deltaTime;
|
transform.position = transform.position + transform.localRotation * Vector3.up * speed * Time.deltaTime; // TODO do with physics (rigidbody)
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnCollisionEnter2D(Collision2D collision) {
|
void OnCollisionEnter2D(Collision2D collision) {
|
||||||
if ( owner == null )
|
if ( owner == null )
|
||||||
return;
|
return;
|
||||||
Debug.Log("Collided");
|
|
||||||
if ( collision.collider.gameObject.tag != owner.tag ) {
|
if ( collision.collider.gameObject.tag != owner.tag ) {
|
||||||
Debug.Log("calc");
|
|
||||||
Mob m = collision.collider.gameObject.GetComponent(typeof(Mob)) as Mob;
|
Mob m = collision.collider.gameObject.GetComponent(typeof(Mob)) as Mob;
|
||||||
if (m != null) {
|
if (m != null) {
|
||||||
m.InflictDamage(damage);
|
m.InflictDamage(damage);
|
||||||
|
|
Loading…
Add table
Reference in a new issue