From 407cbe14dba01166f3ca6e25aafdc65318f1c6fa Mon Sep 17 00:00:00 2001
From: Tristan Roux
Date: Sun, 2 Dec 2018 17:44:03 +0100
Subject: [PATCH] Reworking projectiles.
---
Assets/Prefabs/SlowProjectile.prefab | 2 +-
Assets/Script/PlayerMovement.cs | 28 +++++++++++++++++++++++-----
Assets/Script/Slime.cs | 5 +++++
ProjectSettings/TagManager.asset | 1 +
4 files changed, 30 insertions(+), 6 deletions(-)
diff --git a/Assets/Prefabs/SlowProjectile.prefab b/Assets/Prefabs/SlowProjectile.prefab
index a85e452..25e6727 100644
--- a/Assets/Prefabs/SlowProjectile.prefab
+++ b/Assets/Prefabs/SlowProjectile.prefab
@@ -24,7 +24,7 @@ GameObject:
- component: {fileID: 61265863616950446}
m_Layer: 10
m_Name: SlowProjectile
- m_TagString: Projectile
+ m_TagString: PushProjectile
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
diff --git a/Assets/Script/PlayerMovement.cs b/Assets/Script/PlayerMovement.cs
index 0256860..5800728 100644
--- a/Assets/Script/PlayerMovement.cs
+++ b/Assets/Script/PlayerMovement.cs
@@ -410,7 +410,7 @@ public class PlayerMovement : MonoBehaviour
if(personalty == Personalty.SlowProj && Input.GetButtonDown("Action"))
{
GameObject proj = Instantiate(SlowProjectile, transform.position + Vector3.right * flip, Quaternion.identity);
- proj.GetComponent().velocity = GetDirection(true, true) * projSpeed;
+ proj.GetComponent().velocity = GetDirection(null, true) * projSpeed;
}
//Parry
@@ -556,6 +556,21 @@ public class PlayerMovement : MonoBehaviour
Damage(1);
}
}
+ else if (collision.gameObject.tag == "PushProjectile")
+ {
+ if (parrying)
+ {
+ rb.AddForce(new Vector2(0, parryForce), ForceMode2D.Impulse);
+ Destroy(collision.gameObject);
+ parrying = false;
+ animator.SetBool("isJumping", isJumping);
+ }
+ else
+ {
+ rb.velocity = collision.gameObject.GetComponent().velocity * 5;
+ Destroy(collision.gameObject);
+ }
+ }
else if (collision.gameObject.tag == "DeathZone")
Death();
else if(collision.gameObject.tag == "Door")
@@ -658,19 +673,22 @@ public class PlayerMovement : MonoBehaviour
}
}
- private Vector3 GetDirection(bool useAimCorrection = true, bool fromPlayer = false)
+ private Vector3 GetDirection(bool? useAimCorrection = true, bool fromPlayer = false)
{
if (useController)
{
float Horizontal = Input.GetAxis("Horizontal");
float Vertical = Input.GetAxis("Vertical");
- if (useAimCorrection)
+ if (useAimCorrection == true)
+ {
+ if (Vertical == 0)
+ Vertical = 1;
+ }
+ if(useAimCorrection == null)
{
if (Horizontal == 0 && Vertical < 0.8f)
Horizontal = 0.3f * flip;
- if (Vertical == 0)
- Vertical = 1;
}
return new Vector3(Horizontal, Vertical, 0).normalized;
diff --git a/Assets/Script/Slime.cs b/Assets/Script/Slime.cs
index 3919c29..9fd12a9 100644
--- a/Assets/Script/Slime.cs
+++ b/Assets/Script/Slime.cs
@@ -28,5 +28,10 @@ public class Slime : MonoBehaviour
Destroy(collision.gameObject);
Destroy(gameObject);
}
+ else if (collision.gameObject.tag == "PushProjectile")
+ {
+ rb.velocity = collision.gameObject.GetComponent().velocity * 5;
+ Destroy(collision.gameObject);
+ }
}
}
diff --git a/ProjectSettings/TagManager.asset b/ProjectSettings/TagManager.asset
index cc051b9..8204de1 100644
--- a/ProjectSettings/TagManager.asset
+++ b/ProjectSettings/TagManager.asset
@@ -13,6 +13,7 @@ TagManager:
- Door
- Key
- Projectile
+ - PushProjectile
layers:
- Default
- TransparentFX