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
|
||||
m_Component:
|
||||
- component: {fileID: 4781595464190240}
|
||||
- component: {fileID: 58664560518688016}
|
||||
- component: {fileID: 212185122411066660}
|
||||
- component: {fileID: 114075590146335024}
|
||||
- component: {fileID: 61667207399653724}
|
||||
- component: {fileID: 50031891945467640}
|
||||
m_Layer: 0
|
||||
m_Name: Bullet
|
||||
m_TagString: Untagged
|
||||
|
@ -42,8 +43,28 @@ Transform:
|
|||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!58 &58664560518688016
|
||||
CircleCollider2D:
|
||||
--- !u!50 &50031891945467640
|
||||
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_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 100100000}
|
||||
|
@ -54,9 +75,19 @@ CircleCollider2D:
|
|||
m_IsTrigger: 0
|
||||
m_UsedByEffector: 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
|
||||
m_Radius: 0.05788156
|
||||
m_Size: {x: 0.12197816, y: 0.23143363}
|
||||
m_EdgeRadius: 0
|
||||
--- !u!114 &114075590146335024
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 1
|
||||
|
|
|
@ -26,15 +26,14 @@ public class Bullet : MonoBehaviour {
|
|||
void Update () {
|
||||
if ( owner == null )
|
||||
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) {
|
||||
if ( owner == null )
|
||||
return;
|
||||
Debug.Log("Collided");
|
||||
|
||||
if ( collision.collider.gameObject.tag != owner.tag ) {
|
||||
Debug.Log("calc");
|
||||
Mob m = collision.collider.gameObject.GetComponent(typeof(Mob)) as Mob;
|
||||
if (m != null) {
|
||||
m.InflictDamage(damage);
|
||||
|
|
Loading…
Add table
Reference in a new issue