mirror of
https://github.com/zoriya/Switching-Personalities.git
synced 2025-12-06 06:36:10 +00:00
Reworking projectiles.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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<Rigidbody2D>().velocity = GetDirection(true, true) * projSpeed;
|
||||
proj.GetComponent<Rigidbody2D>().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<Rigidbody2D>().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;
|
||||
|
||||
@@ -28,5 +28,10 @@ public class Slime : MonoBehaviour
|
||||
Destroy(collision.gameObject);
|
||||
Destroy(gameObject);
|
||||
}
|
||||
else if (collision.gameObject.tag == "PushProjectile")
|
||||
{
|
||||
rb.velocity = collision.gameObject.GetComponent<Rigidbody2D>().velocity * 5;
|
||||
Destroy(collision.gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ TagManager:
|
||||
- Door
|
||||
- Key
|
||||
- Projectile
|
||||
- PushProjectile
|
||||
layers:
|
||||
- Default
|
||||
- TransparentFX
|
||||
|
||||
Reference in New Issue
Block a user