- Home /
Question by
hamoo7dfuad · 5 days ago ·
c#
Adding bouncing force to the left side
Hi, I made a bounce pad that works perfectly but I wanted to make another bounce pad that pushes you to the left side I have tried replacing Vector2.up to Vector2.left it worked but it's so weak is there another way to do it. I hope that I explained my issue well.
public float Bounce;
public bool up;
public bool Left;
private void OnCollisionEnter2D(Collision2D collision)
{
if (collision.gameObject.CompareTag("Player") || collision.gameObject.CompareTag("Ball"))
{
if (up)
{
collision.gameObject.GetComponent<Rigidbody2D>().AddForce(Vector2.up * Bounce, ForceMode2D.Impulse);
}
if (Left)
{
collision.gameObject.GetComponent<Rigidbody2D>().AddForce(Vector2.up * Bounce, ForceMode2D.Impulse);
}
}
}
Comment