Skip to content
Snippets Groups Projects
Commit 76aa64f0 authored by Malik Rafsanjani's avatar Malik Rafsanjani
Browse files

feat: add bow arrow ui

parent 6c0ea38b
Branches
Tags
No related merge requests found
......@@ -13,7 +13,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 100002, guid: 432dd2b7c2581c744a40ca43b1307c17, type: 3}
propertyPath: m_Name
value: Arrow
value: Arrow Variant
objectReference: {fileID: 0}
- target: {fileID: 100002, guid: 432dd2b7c2581c744a40ca43b1307c17, type: 3}
propertyPath: m_Layer
......@@ -23,9 +23,21 @@ PrefabInstance:
propertyPath: m_RootOrder
value: 0
objectReference: {fileID: 0}
- target: {fileID: 400002, guid: 432dd2b7c2581c744a40ca43b1307c17, type: 3}
propertyPath: m_LocalScale.x
value: 0.1
objectReference: {fileID: 0}
- target: {fileID: 400002, guid: 432dd2b7c2581c744a40ca43b1307c17, type: 3}
propertyPath: m_LocalScale.y
value: 0.1
objectReference: {fileID: 0}
- target: {fileID: 400002, guid: 432dd2b7c2581c744a40ca43b1307c17, type: 3}
propertyPath: m_LocalScale.z
value: 0.1
objectReference: {fileID: 0}
- target: {fileID: 400002, guid: 432dd2b7c2581c744a40ca43b1307c17, type: 3}
propertyPath: m_LocalPosition.x
value: -0
value: 0.24514952
objectReference: {fileID: 0}
- target: {fileID: 400002, guid: 432dd2b7c2581c744a40ca43b1307c17, type: 3}
propertyPath: m_LocalPosition.y
......@@ -33,19 +45,19 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 400002, guid: 432dd2b7c2581c744a40ca43b1307c17, type: 3}
propertyPath: m_LocalPosition.z
value: 0
value: 0.09089899
objectReference: {fileID: 0}
- target: {fileID: 400002, guid: 432dd2b7c2581c744a40ca43b1307c17, type: 3}
propertyPath: m_LocalRotation.w
value: 1
value: 0.9823047
objectReference: {fileID: 0}
- target: {fileID: 400002, guid: 432dd2b7c2581c744a40ca43b1307c17, type: 3}
propertyPath: m_LocalRotation.x
value: 0
value: -0
objectReference: {fileID: 0}
- target: {fileID: 400002, guid: 432dd2b7c2581c744a40ca43b1307c17, type: 3}
propertyPath: m_LocalRotation.y
value: -0
value: -0.18729018
objectReference: {fileID: 0}
- target: {fileID: 400002, guid: 432dd2b7c2581c744a40ca43b1307c17, type: 3}
propertyPath: m_LocalRotation.z
......@@ -57,7 +69,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 400002, guid: 432dd2b7c2581c744a40ca43b1307c17, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
value: -21.589
objectReference: {fileID: 0}
- target: {fileID: 400002, guid: 432dd2b7c2581c744a40ca43b1307c17, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
......@@ -70,20 +82,6 @@ GameObject:
m_CorrespondingSourceObject: {fileID: 100002, guid: 432dd2b7c2581c744a40ca43b1307c17, type: 3}
m_PrefabInstance: {fileID: 5605313144142672465}
m_PrefabAsset: {fileID: 0}
--- !u!64 &4712171908962713240
MeshCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5605313144142574835}
m_Material: {fileID: 0}
m_IsTrigger: 1
m_Enabled: 1
serializedVersion: 4
m_Convex: 1
m_CookingOptions: 30
m_Mesh: {fileID: 0}
--- !u!54 &1119277001401672218
Rigidbody:
m_ObjectHideFlags: 0
......@@ -92,10 +90,10 @@ Rigidbody:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5605313144142574835}
serializedVersion: 2
m_Mass: 1
m_Mass: 0.05
m_Drag: 0
m_AngularDrag: 0.05
m_UseGravity: 1
m_UseGravity: 0
m_IsKinematic: 0
m_Interpolate: 0
m_Constraints: 0
......@@ -114,4 +112,3 @@ MonoBehaviour:
m_EditorClassIdentifier:
damage: 200
torque: 10
rigidbody: {fileID: 1119277001401672218}
......@@ -6923,8 +6923,20 @@ PrefabInstance:
m_Modifications:
- target: {fileID: 1119277001401672218, guid: 43ff8f8509c207f43a1a3b1c1520cdc6, type: 3}
propertyPath: m_UseGravity
value: 1
objectReference: {fileID: 0}
- target: {fileID: 1119277001401672218, guid: 43ff8f8509c207f43a1a3b1c1520cdc6, type: 3}
propertyPath: m_AngularDrag
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5467698248896174944, guid: 43ff8f8509c207f43a1a3b1c1520cdc6, type: 3}
propertyPath: m_Enabled
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5467698248896174944, guid: 43ff8f8509c207f43a1a3b1c1520cdc6, type: 3}
propertyPath: m_IsTrigger
value: 1
objectReference: {fileID: 0}
- target: {fileID: 5605313144142574835, guid: 43ff8f8509c207f43a1a3b1c1520cdc6, type: 3}
propertyPath: m_Name
value: Arrow
......
......@@ -10,21 +10,21 @@ public class PlayerArrow : MonoBehaviour
[SerializeField]
private float torque;
[SerializeField]
private Rigidbody rigidbody;
private Rigidbody rb;
private bool didHit;
public void Shoot(Vector3 force)
private void Awake()
{
rigidbody.isKinematic = true;
rigidbody.AddForce(force, ForceMode.Impulse);
rigidbody.AddTorque(transform.right * torque);
transform.SetParent(null);
rb = GetComponent<Rigidbody>();
rb.isKinematic = false;
Destroy(gameObject, 10);
}
void OnTriggerEnter(Collider other)
{
Debug.Log("Hitting " + other);
if (didHit) return;
didHit = true;
......@@ -33,9 +33,9 @@ public class PlayerArrow : MonoBehaviour
enemyHealth.TakeDamage(damage, enemyHealth.transform.position);
}
rigidbody.velocity = Vector3.zero;
rigidbody.angularVelocity = Vector3.zero;
rigidbody.isKinematic = true;
rb.velocity = Vector3.zero;
rb.angularVelocity = Vector3.zero;
rb.isKinematic = true;
transform.SetParent(other.transform);
}
}
......@@ -14,7 +14,12 @@ public class PlayerBow : MonoBehaviour
private Transform arrowSpawnPoint;
private PlayerArrow curArrow;
private bool isReload;
private bool isReload = false;
void Awake()
{
ReloadArrow();
}
public void Reload()
{
......@@ -28,7 +33,7 @@ public class PlayerBow : MonoBehaviour
if (Input.GetKeyDown(KeyCode.J))
{
Debug.Log("Click J");
Shoot(50);
Shoot(5);
}
}
......@@ -36,18 +41,21 @@ public class PlayerBow : MonoBehaviour
private IEnumerator ReloadCorutine()
{
yield return new WaitForSeconds(reloadTime);
curArrow = Instantiate(playerArrowPrefab, arrowSpawnPoint);
curArrow.transform.localPosition = Vector3.zero;
ReloadArrow();
}
private void ReloadArrow()
{
/*curArrow.transform.SetParent(arrowSpawnPoint.transform, false);*/
isReload = false;
}
public void Shoot(float power)
{
if (isReload || curArrow == null) return;
var force = arrowSpawnPoint.TransformDirection(Vector3.forward * power);
curArrow.Shoot(force);
curArrow = null;
Debug.Log("isReload: " + isReload);
curArrow = Instantiate(playerArrowPrefab, transform.position, arrowSpawnPoint.transform.rotation);
var force = curArrow.transform.forward;
curArrow.GetComponent<Rigidbody>().AddRelativeForce(force * -20);
Reload();
}
......
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