hello im new but i nedd help with a script that make my player get more knockback if its on lower hp im still dont now how to get this kind of knockback here are my scripts c#
my player hp:
public class hpP1 : MonoBehaviour
{
public const int maxHealth = 100;
public int currentHealth = maxHealth;
public void TakeDamage(int amount)
{
currentHealth -= amount;
if (currentHealth <= 0)
{
currentHealth = 0;
Debug.Log("Dead!");
}
}
void OnCollisionEnter(Collision col)
{
if (col.gameObject.tag == "bullet")
{
currentHealth -= 5;
transform.localScale += new Vector3(0.0018f, 0.0018f, 0.0018f);
Vector3 direction = (transform.position - col.transform.position).normalized;
}
}
}
and my bullet shooting script:
{
public Rigidbody projectile;
public float speed = 20;
// Update is called once per frame
void Update()
{
if (Input.GetButtonDown("Fire1"))
{
Rigidbody instantiatedProjectile = Instantiate(projectile, transform.position, transform.rotation) as Rigidbody;
instantiatedProjectile.velocity = transform.TransformDirection(new Vector3(speed, 0, 0));
}
}
}
its a 3d platformer like SSB but then with shooting
so hopes somebody helps me with this