XF52N4U7HWXOF4PDSCR7LCUENLTSXLWEZGS2IJ6562KYI567Z2GAC
fileFormatVersion: 2
guid: ce462ca638a52744a84f952028f36ae6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {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 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 2775200704764093955, guid: 689a4763a3cde4b46a7c011ddb15ea97,
type: 3}
m_PrefabInstance: {fileID: 1446124018}
m_PrefabAsset: {fileID: 0}
--- !u!4 &140170572 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 2775200704764093956, guid: 689a4763a3cde4b46a7c011ddb15ea97,
type: 3}
m_PrefabInstance: {fileID: 1446124018}
m_PrefabAsset: {fileID: 0}
--- !u!54 &140170573
Rigidbody:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 140170566}
serializedVersion: 2
m_Mass: 70
m_Drag: 0.2
m_AngularDrag: 0.05
m_UseGravity: 1
m_IsKinematic: 1
m_Interpolate: 0
m_Constraints: 0
m_CollisionDetection: 0
serializedVersion: 6
m_Component:
- component: {fileID: 1194535747}
- component: {fileID: 1194535748}
m_Layer: 0
m_Name: Tester
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1194535747
Transform:
m_ObjectHideFlags: 0
m_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: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 12
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1194535748
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1194535746}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: ce462ca638a52744a84f952028f36ae6, type: 3}
m_Name:
m_EditorClassIdentifier:
forceAmount: 100
affected: {fileID: 140170572}
pusher: {fileID: 1501202978}
unitMovementLayerMask:
serializedVersion: 2
m_Bits: 64
forceMode: 1
--- !u!1001 &1446124018
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 2775200704764093955, guid: 689a4763a3cde4b46a7c011ddb15ea97,
type: 3}
propertyPath: m_Name
value: PartyMember (2)
objectReference: {fileID: 0}
- target: {fileID: 2775200704764093956, guid: 689a4763a3cde4b46a7c011ddb15ea97,
type: 3}
propertyPath: m_RootOrder
value: 11
objectReference: {fileID: 0}
- target: {fileID: 2775200704764093956, guid: 689a4763a3cde4b46a7c011ddb15ea97,
type: 3}
propertyPath: m_LocalScale.x
value: 1
objectReference: {fileID: 0}
- target: {fileID: 2775200704764093956, guid: 689a4763a3cde4b46a7c011ddb15ea97,
type: 3}
propertyPath: m_LocalScale.y
value: 1
objectReference: {fileID: 0}
- target: {fileID: 2775200704764093956, guid: 689a4763a3cde4b46a7c011ddb15ea97,
type: 3}
propertyPath: m_LocalScale.z
value: 1
objectReference: {fileID: 0}
- target: {fileID: 2775200704764093956, guid: 689a4763a3cde4b46a7c011ddb15ea97,
type: 3}
propertyPath: m_LocalPosition.x
value: 51.6
objectReference: {fileID: 0}
- target: {fileID: 2775200704764093956, guid: 689a4763a3cde4b46a7c011ddb15ea97,
type: 3}
propertyPath: m_LocalPosition.y
value: 1
objectReference: {fileID: 0}
- target: {fileID: 2775200704764093956, guid: 689a4763a3cde4b46a7c011ddb15ea97,
type: 3}
propertyPath: m_LocalPosition.z
value: 61.78
objectReference: {fileID: 0}
- target: {fileID: 2775200704764093956, guid: 689a4763a3cde4b46a7c011ddb15ea97,
type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 2775200704764093956, guid: 689a4763a3cde4b46a7c011ddb15ea97,
type: 3}
propertyPath: m_LocalRotation.x
value: -0
objectReference: {fileID: 0}
- target: {fileID: 2775200704764093956, guid: 689a4763a3cde4b46a7c011ddb15ea97,
type: 3}
propertyPath: m_LocalRotation.y
value: -0
objectReference: {fileID: 0}
- target: {fileID: 2775200704764093956, guid: 689a4763a3cde4b46a7c011ddb15ea97,
type: 3}
propertyPath: m_LocalRotation.z
value: -0
objectReference: {fileID: 0}
- target: {fileID: 2775200704764093956, guid: 689a4763a3cde4b46a7c011ddb15ea97,
type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2775200704764093956, guid: 689a4763a3cde4b46a7c011ddb15ea97,
type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2775200704764093956, guid: 689a4763a3cde4b46a7c011ddb15ea97,
type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7783687589460546184, guid: 689a4763a3cde4b46a7c011ddb15ea97,
type: 3}
propertyPath: m_Enabled
value: 0
objectReference: {fileID: 0}
m_RemovedComponents:
- {fileID: 7783687589460546184, guid: 689a4763a3cde4b46a7c011ddb15ea97, type: 3}
m_SourcePrefab: {fileID: 100100000, guid: 689a4763a3cde4b46a7c011ddb15ea97, type: 3}