boing boing mf
This commit is contained in:
		@@ -4,15 +4,18 @@ using UnityEngine;
 | 
			
		||||
 | 
			
		||||
public class WaterBehavior : MonoBehaviour
 | 
			
		||||
{
 | 
			
		||||
    // Start is called before the first frame update
 | 
			
		||||
    void Start()
 | 
			
		||||
    public Rigidbody2D RB;
 | 
			
		||||
 | 
			
		||||
    [SerializeField] private float bounceForce = 2;
 | 
			
		||||
 | 
			
		||||
    void OnCollisionEnter2D(Collision2D col)
 | 
			
		||||
    {
 | 
			
		||||
        
 | 
			
		||||
        Bounce();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // Update is called once per frame
 | 
			
		||||
    void Update()
 | 
			
		||||
    private void Bounce()
 | 
			
		||||
    {
 | 
			
		||||
        
 | 
			
		||||
        RB.velocity = new Vector2(RB.velocity.x, -(RB.velocity.y));
 | 
			
		||||
        RB.AddForce(RB.velocity * bounceForce, ForceMode2D.Impulse);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user