BoulderFix Script added

This commit is contained in:
GungHolo
2023-06-07 11:23:08 +02:00
parent 645c21bb95
commit 0b69c75627
6 changed files with 92 additions and 4 deletions

View File

@@ -12,6 +12,7 @@ GameObject:
- component: {fileID: 2931262115788872084}
- component: {fileID: 8547966821854904316}
- component: {fileID: 5950443230785378104}
- component: {fileID: 8814372359582481795}
m_Layer: 0
m_Name: boulder
m_TagString: PressurePlatable
@@ -133,3 +134,17 @@ Rigidbody2D:
m_SleepingMode: 1
m_CollisionDetection: 0
m_Constraints: 4
--- !u!114 &8814372359582481795
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2931262115788872085}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 2de907f50474c5b40bb803c5f51866f7, type: 3}
m_Name:
m_EditorClassIdentifier:
frictionless: {fileID: 6200000, guid: 9a162dcdc92b4194ba53630f8785bed1, type: 2}
frictionful: {fileID: 6200000, guid: b200e3c05da9fc94486c5941e94bd715, type: 2}

View File

@@ -0,0 +1,43 @@
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 = 8;
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;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2de907f50474c5b40bb803c5f51866f7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: