ofb/Assets/Scripts/BounceBehavior.cs
2023-05-04 13:31:41 -07:00

22 lines
459 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class WaterBehavior : MonoBehaviour
{
public Rigidbody2D RB;
[SerializeField] private float bounceForce = 2;
void OnCollisionEnter2D(Collision2D col)
{
Bounce();
}
private void Bounce()
{
RB.velocity = new Vector2(RB.velocity.x, -(RB.velocity.y));
RB.AddForce(RB.velocity * bounceForce, ForceMode2D.Impulse);
}
}