XF52N4U7HWXOF4PDSCR7LCUENLTSXLWEZGS2IJ6562KYI567Z2GAC fileFormatVersion: 2guid: ce462ca638a52744a84f952028f36ae6MonoImporter:externalObjects: {}serializedVersion: 2defaultReferences: []executionOrder: 0icon: {instanceID: 0}userData:assetBundleName:assetBundleVariant:
using System.Collections;using System.Collections.Generic;using UnityEngine;using UnityEngine.AI;using UnityEngine.EventSystems;public class Tester : MonoBehaviour{[SerializeField] Vector3 forceToApply;[SerializeField] Transform affected;[SerializeField] LayerMask unitMovementLayerMask;[SerializeField] ForceMode forceMode;Renderer r;Rigidbody rb;NavMeshAgent nma;bool pushed;Vector3 resetPosition;private void Start() {r = affected.GetComponent<Renderer>();rb = affected.GetComponent<Rigidbody>();nma = affected.GetComponent<NavMeshAgent>();resetPosition = affected.transform.position;reset();}void Update(){if (Input.GetKeyDown(KeyCode.T)) {pushed = true;}if (Input.GetKeyDown(KeyCode.B) && !EventSystem.current.IsPointerOverGameObject()) {Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);if (Physics.Raycast(ray, out RaycastHit hit)) {Transform objectHit = hit.transform;if (unitMovementLayerMask.IsLayerInMask(objectHit.gameObject.layer)) {nma.Warp(hit.point);}}}if (Input.GetKeyDown(KeyCode.R)){reset();}if (Input.GetKeyDown(KeyCode.P)) {print($"Velocity ({rb.velocity}), Magnitude {rb.velocity.magnitude}");print($"world bounds {r.bounds} local bounds {r.localBounds}");}}void FixedUpdate() {if (!rb.isKinematic && nma.isOnNavMesh && rb.velocity.sqrMagnitude < 0.25f) {if (Physics.Raycast(affected.transform.position,Vector3.down,r.bounds.extents.y + 0.1f,unitMovementLayerMask)) {rb.isKinematic = true;nma.updatePosition = true;nma.updateRotation = true;nma.Warp(affected.transform.position);}//nma.enabled = true;}if (pushed) {// nma.enabled = false;nma.updatePosition = false;nma.updateRotation = false;rb.isKinematic = false;rb.AddForce(forceToApply, forceMode);pushed = false;}}private void reset(){rb.isKinematic = true;nma.updatePosition = true;nma.updateRotation = true;nma.enabled = true;pushed = false;affected.transform.position = resetPosition;}}
Bounds bounds = selected.GetComponent<Renderer>().bounds;this.transform.position = new Vector3(bounds.center.x, 0, bounds.center.z);this.transform.localScale = new Vector3(bounds.size.x, bounds.size.y, bounds.size.z) * scale;this.transform.parent = selected;selectionUI.gameObject.SetActive(true);
if (selected) {Bounds bounds = selected.GetComponent<Renderer>().bounds;this.transform.position = new Vector3(bounds.center.x, 0, bounds.center.z);//this.transform.localScale = new Vector3(bounds.size.x, bounds.size.y, bounds.size.z) * scale;}
--- !u!1 &140170566 strippedGameObject:m_CorrespondingSourceObject: {fileID: 2775200704764093955, guid: 689a4763a3cde4b46a7c011ddb15ea97,type: 3}m_PrefabInstance: {fileID: 1446124018}m_PrefabAsset: {fileID: 0}--- !u!4 &140170572 strippedTransform:m_CorrespondingSourceObject: {fileID: 2775200704764093956, guid: 689a4763a3cde4b46a7c011ddb15ea97,type: 3}m_PrefabInstance: {fileID: 1446124018}m_PrefabAsset: {fileID: 0}--- !u!54 &140170573Rigidbody:m_ObjectHideFlags: 0m_CorrespondingSourceObject: {fileID: 0}m_PrefabInstance: {fileID: 0}m_PrefabAsset: {fileID: 0}m_GameObject: {fileID: 140170566}serializedVersion: 2m_Mass: 70m_Drag: 0.2m_AngularDrag: 0.05m_UseGravity: 1m_IsKinematic: 1m_Interpolate: 0m_Constraints: 0m_CollisionDetection: 0
serializedVersion: 6m_Component:- component: {fileID: 1194535747}- component: {fileID: 1194535748}m_Layer: 0m_Name: Testerm_TagString: Untaggedm_Icon: {fileID: 0}m_NavMeshLayer: 0m_StaticEditorFlags: 0m_IsActive: 1--- !u!4 &1194535747Transform:m_ObjectHideFlags: 0m_CorrespondingSourceObject: {fileID: 0}m_PrefabInstance: {fileID: 0}m_PrefabAsset: {fileID: 0}m_GameObject: {fileID: 1194535746}m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}m_LocalPosition: {x: 56.26513, y: 9.839486, z: 42.116863}m_LocalScale: {x: 1, y: 1, z: 1}m_ConstrainProportionsScale: 0m_Children: []m_Father: {fileID: 0}m_RootOrder: 12m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}--- !u!114 &1194535748MonoBehaviour:m_ObjectHideFlags: 0m_CorrespondingSourceObject: {fileID: 0}m_PrefabInstance: {fileID: 0}m_PrefabAsset: {fileID: 0}m_GameObject: {fileID: 1194535746}m_Enabled: 1m_EditorHideFlags: 0m_Script: {fileID: 11500000, guid: ce462ca638a52744a84f952028f36ae6, type: 3}m_Name:m_EditorClassIdentifier:forceAmount: 100affected: {fileID: 140170572}pusher: {fileID: 1501202978}unitMovementLayerMask:serializedVersion: 2m_Bits: 64forceMode: 1
--- !u!1001 &1446124018PrefabInstance:m_ObjectHideFlags: 0serializedVersion: 2m_Modification:m_TransformParent: {fileID: 0}m_Modifications:- target: {fileID: 2775200704764093955, guid: 689a4763a3cde4b46a7c011ddb15ea97,type: 3}propertyPath: m_Namevalue: PartyMember (2)objectReference: {fileID: 0}- target: {fileID: 2775200704764093956, guid: 689a4763a3cde4b46a7c011ddb15ea97,type: 3}propertyPath: m_RootOrdervalue: 11objectReference: {fileID: 0}- target: {fileID: 2775200704764093956, guid: 689a4763a3cde4b46a7c011ddb15ea97,type: 3}propertyPath: m_LocalScale.xvalue: 1objectReference: {fileID: 0}- target: {fileID: 2775200704764093956, guid: 689a4763a3cde4b46a7c011ddb15ea97,type: 3}propertyPath: m_LocalScale.yvalue: 1objectReference: {fileID: 0}- target: {fileID: 2775200704764093956, guid: 689a4763a3cde4b46a7c011ddb15ea97,type: 3}propertyPath: m_LocalScale.zvalue: 1objectReference: {fileID: 0}- target: {fileID: 2775200704764093956, guid: 689a4763a3cde4b46a7c011ddb15ea97,type: 3}propertyPath: m_LocalPosition.xvalue: 51.6objectReference: {fileID: 0}- target: {fileID: 2775200704764093956, guid: 689a4763a3cde4b46a7c011ddb15ea97,type: 3}propertyPath: m_LocalPosition.yvalue: 1objectReference: {fileID: 0}- target: {fileID: 2775200704764093956, guid: 689a4763a3cde4b46a7c011ddb15ea97,type: 3}propertyPath: m_LocalPosition.zvalue: 61.78objectReference: {fileID: 0}- target: {fileID: 2775200704764093956, guid: 689a4763a3cde4b46a7c011ddb15ea97,type: 3}propertyPath: m_LocalRotation.wvalue: 1objectReference: {fileID: 0}- target: {fileID: 2775200704764093956, guid: 689a4763a3cde4b46a7c011ddb15ea97,type: 3}propertyPath: m_LocalRotation.xvalue: -0objectReference: {fileID: 0}- target: {fileID: 2775200704764093956, guid: 689a4763a3cde4b46a7c011ddb15ea97,type: 3}propertyPath: m_LocalRotation.yvalue: -0objectReference: {fileID: 0}- target: {fileID: 2775200704764093956, guid: 689a4763a3cde4b46a7c011ddb15ea97,type: 3}propertyPath: m_LocalRotation.zvalue: -0objectReference: {fileID: 0}- target: {fileID: 2775200704764093956, guid: 689a4763a3cde4b46a7c011ddb15ea97,type: 3}propertyPath: m_LocalEulerAnglesHint.xvalue: 0objectReference: {fileID: 0}- target: {fileID: 2775200704764093956, guid: 689a4763a3cde4b46a7c011ddb15ea97,type: 3}propertyPath: m_LocalEulerAnglesHint.yvalue: 0objectReference: {fileID: 0}- target: {fileID: 2775200704764093956, guid: 689a4763a3cde4b46a7c011ddb15ea97,type: 3}propertyPath: m_LocalEulerAnglesHint.zvalue: 0objectReference: {fileID: 0}- target: {fileID: 7783687589460546184, guid: 689a4763a3cde4b46a7c011ddb15ea97,type: 3}propertyPath: m_Enabledvalue: 0objectReference: {fileID: 0}m_RemovedComponents:- {fileID: 7783687589460546184, guid: 689a4763a3cde4b46a7c011ddb15ea97, type: 3}m_SourcePrefab: {fileID: 100100000, guid: 689a4763a3cde4b46a7c011ddb15ea97, type: 3}