Add bobbing for gun

This commit is contained in:
Sofia 2019-08-14 19:21:27 +03:00
parent acee983f6d
commit 0391622a11
2 changed files with 84 additions and 11 deletions

View File

@ -1,5 +1,37 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &3306765774511797525
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1528725660408968915}
m_Layer: 8
m_Name: Bobbing
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1528725660408968915
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3306765774511797525}
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_Children:
- {fileID: 4462327695001662283}
- {fileID: 427857587156450783}
m_Father: {fileID: 4462327694118370271}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &4462327694118370270
GameObject:
m_ObjectHideFlags: 0
@ -9,9 +41,11 @@ GameObject:
serializedVersion: 6
m_Component:
- component: {fileID: 4462327694118370271}
- component: {fileID: 1737862779447396268}
- component: {fileID: 4462327694118370268}
- component: {fileID: 4462327694118370269}
m_Layer: 0
- component: {fileID: 3522608540502111974}
m_Layer: 8
m_Name: Revolver
m_TagString: Untagged
m_Icon: {fileID: 0}
@ -29,11 +63,31 @@ Transform:
m_LocalPosition: {x: 1.947, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 4462327695001662283}
- {fileID: 427857587156450783}
- {fileID: 1528725660408968915}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!50 &1737862779447396268
Rigidbody2D:
serializedVersion: 4
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4462327694118370270}
m_BodyType: 0
m_Simulated: 1
m_UseFullKinematicContacts: 0
m_UseAutoMass: 0
m_Mass: 0.4
m_LinearDrag: 5
m_AngularDrag: 12
m_GravityScale: 0
m_Material: {fileID: 0}
m_Interpolate: 0
m_SleepingMode: 1
m_CollisionDetection: 0
m_Constraints: 4
--- !u!61 &4462327694118370268
BoxCollider2D:
m_ObjectHideFlags: 0
@ -44,7 +98,7 @@ BoxCollider2D:
m_Enabled: 1
m_Density: 1
m_Material: {fileID: 0}
m_IsTrigger: 1
m_IsTrigger: 0
m_UsedByEffector: 0
m_UsedByComposite: 0
m_Offset: {x: 0, y: 0}
@ -76,6 +130,24 @@ MonoBehaviour:
Sprite: {fileID: 4462327695001662280}
BulletHole: {fileID: 427857587156450783}
Cooldown: 0.2
--- !u!114 &3522608540502111974
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4462327694118370270}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e796ba4c6f7efc449a10ed13ee42e34f, type: 3}
m_Name:
m_EditorClassIdentifier:
BobbedTransform: {fileID: 1528725660408968915}
BobbingMultiplier: 1
BobbingGravity: 0.07
BobbingLaunchSpeed: 0.05
BobbingFrequency: 0
BobbingDirection: {x: 0, y: 1}
--- !u!1 &4462327695001662282
GameObject:
m_ObjectHideFlags: 0
@ -86,7 +158,7 @@ GameObject:
m_Component:
- component: {fileID: 4462327695001662283}
- component: {fileID: 4462327695001662280}
m_Layer: 0
m_Layer: 8
m_Name: revolver
m_TagString: Untagged
m_Icon: {fileID: 0}
@ -104,7 +176,7 @@ Transform:
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 4462327694118370271}
m_Father: {fileID: 1528725660408968915}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!212 &4462327695001662280
@ -165,7 +237,7 @@ GameObject:
serializedVersion: 6
m_Component:
- component: {fileID: 427857587156450783}
m_Layer: 0
m_Layer: 8
m_Name: BulletHole
m_TagString: Untagged
m_Icon: {fileID: 0}
@ -180,9 +252,9 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5364776498526555370}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0.811, y: 0.129, z: 0}
m_LocalPosition: {x: 0.8109999, y: 0.129, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 4462327694118370271}
m_Father: {fileID: 1528725660408968915}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}

View File

@ -20,15 +20,16 @@ namespace Saltosion.OneWeapon.Guns {
}
}
void OnTriggerEnter2D(Collider2D collider) {
void OnCollisionEnter2D(Collision2D collision) {
if (IsHeld) {
return;
}
PlayerController Player = collider.GetComponent<PlayerController>();
PlayerController Player = collision.collider.GetComponent<PlayerController>();
if (Player != null) {
IsHeld = true;
Player.SetGun(this);
Destroy(GetComponent<BoxCollider2D>());
Destroy(GetComponent<Rigidbody2D>());
}
}