47 lines
818 B
C#
Raw Permalink Normal View History

2023-06-07 11:23:08 +02:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BoulderFix : MonoBehaviour
{
private Rigidbody2D rb;
private BoxCollider2D bc;
[SerializeField] private PhysicsMaterial2D frictionless;
[SerializeField] private PhysicsMaterial2D frictionful;
void Start()
{
rb = GetComponent<Rigidbody2D>();
bc = GetComponent<BoxCollider2D>();
rb.mass = 5;
2023-06-07 11:23:08 +02:00
rb.drag = 1;
}
// Update is called once per frame
void Update()
{
}
void OnCollisionEnter2D(Collision2D col)
{
2023-06-22 11:07:25 +02:00
2023-06-07 11:23:08 +02:00
bc.sharedMaterial = frictionless;
rb.drag = 3;
}
void OnCollisionExit2D(Collision2D col)
{
bc.sharedMaterial = frictionful;
rb.drag = 1;
}
2023-06-22 11:07:25 +02:00
2023-06-07 11:23:08 +02:00
}