NPC!!
This commit is contained in:
71
Assets/Scripts/NPC.cs
Normal file
71
Assets/Scripts/NPC.cs
Normal 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;
|
||||
|
||||
// }
|
||||
}
|
||||
|
||||
}
|
||||
11
Assets/Scripts/NPC.cs.meta
Normal file
11
Assets/Scripts/NPC.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b7391613e08a1e4419083635391e73ec
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user