This commit is contained in:
magn9775
2024-04-19 16:04:04 +02:00
parent de7bbbb22a
commit 65b226d920
9 changed files with 2134 additions and 316 deletions

71
Assets/Scripts/NPC.cs Normal file
View File

@@ -0,0 +1,71 @@
using System.Collections;
using System.Collections.Generic;
using Unity.MLAgents.SideChannels;
using UnityEngine;
public class NPC : MonoBehaviour
{
private Rigidbody[] RBchildren;
// Start is called before the first frame update
void Start()
{
foreach (Transform g in transform.GetComponentsInChildren<Transform>())
{
try
{
var rb = g.GetComponent<Rigidbody>();
rb.useGravity = false;
}
catch (System.Exception)
{
continue;
}
}
// for (int i = 0; i < RBchildren.Length; i++)
// {
// RBchildren[i].useGravity = false;
// }
}
// Update is called once per frame
void Update()
{
}
private void OnCollisionEnter(Collision collision)
{
if (collision.gameObject.tag == "Player")
{
foreach (Transform g in transform.GetComponentsInChildren<Transform>())
{
try
{
var rb = g.GetComponent<Rigidbody>();
rb.useGravity = true;
rb.isKinematic = false;
}
catch (System.Exception)
{
continue;
}
}
}
// for (int i = 0; i < RBchildren.Length; i++)
// {
// RBchildren[i].useGravity = true;
// RBchildren[i].isKinematic = false;
// }
}
}

View File

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