44 lines
803 B
C#
44 lines
803 B
C#
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;
|
|
rb.drag = 1;
|
|
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
|
|
}
|
|
|
|
void OnCollisionEnter2D(Collision2D col)
|
|
{
|
|
bc.sharedMaterial = frictionless;
|
|
rb.drag = 3;
|
|
|
|
}
|
|
|
|
void OnCollisionExit2D(Collision2D col)
|
|
{
|
|
bc.sharedMaterial = frictionful;
|
|
rb.drag = 1;
|
|
|
|
}
|
|
|
|
}
|