Add new meta files and interfaces for project structure
This commit is contained in:
@@ -0,0 +1,117 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 8
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Arrow
|
||||
m_Shader: {fileID: 211, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_Parent: {fileID: 0}
|
||||
m_ModifiedSerializedProperties: 0
|
||||
m_ValidKeywords:
|
||||
- _ALPHABLEND_ON
|
||||
- _COLORCOLOR_ON
|
||||
m_InvalidKeywords: []
|
||||
m_LightmapFlags: 0
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: 3000
|
||||
stringTagMap:
|
||||
RenderType: Transparent
|
||||
disabledShaderPasses:
|
||||
- GRABPASS
|
||||
m_LockedProperties:
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
- _BumpMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DecalTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailAlbedoMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailMask:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailNormalMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _EmissionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MainTex:
|
||||
m_Texture: {fileID: 2800000, guid: 5de2706722ecf4e7797812f980546c1a, type: 3}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MetallicGlossMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _OcclusionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _ParallaxMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Ints: []
|
||||
m_Floats:
|
||||
- _BlendOp: 0
|
||||
- _BumpScale: 1
|
||||
- _CameraFadingEnabled: 0
|
||||
- _CameraFarFadeDistance: 2
|
||||
- _CameraNearFadeDistance: 1
|
||||
- _ColorMode: 4
|
||||
- _Cull: 2
|
||||
- _Cutoff: 0.5
|
||||
- _DetailNormalMapScale: 1
|
||||
- _DistortionBlend: 0.5
|
||||
- _DistortionEnabled: 0
|
||||
- _DistortionStrength: 1
|
||||
- _DistortionStrengthScaled: 0
|
||||
- _DstBlend: 10
|
||||
- _EmissionEnabled: 0
|
||||
- _FlipbookMode: 0
|
||||
- _GlossMapScale: 1
|
||||
- _Glossiness: 0.5
|
||||
- _GlossyReflections: 1
|
||||
- _InvFade: 1
|
||||
- _LightingEnabled: 0
|
||||
- _Metallic: 0
|
||||
- _Mode: 2
|
||||
- _OcclusionStrength: 1
|
||||
- _Parallax: 0.02
|
||||
- _Shininess: 0.08769007
|
||||
- _SmoothnessTextureChannel: 0
|
||||
- _SoftParticlesEnabled: 0
|
||||
- _SoftParticlesFarFadeDistance: 1
|
||||
- _SoftParticlesNearFadeDistance: 0
|
||||
- _SpecularHighlights: 1
|
||||
- _SrcBlend: 5
|
||||
- _UVSec: 0
|
||||
- _ZWrite: 0
|
||||
m_Colors:
|
||||
- _CameraFadeParams: {r: 0, g: Infinity, b: 0, a: 0}
|
||||
- _Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _ColorAddSubDiff: {r: -1, g: 0, b: 0, a: 0}
|
||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
- _SoftParticleFadeParams: {r: 0, g: 0, b: 0, a: 0}
|
||||
- _SpecColor: {r: 0.8708022, g: 0.8708022, b: 0.8708022, a: 0}
|
||||
- _TintColor: {r: 1, g: 1, b: 1, a: 0.49411765}
|
||||
m_BuildTextureStacks: []
|
||||
--- !u!1002 &2100001
|
||||
EditorExtensionImpl:
|
||||
serializedVersion: 6
|
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6ac95c099f0e2ad4d90aa8dbf92a6f5d
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 87744
|
||||
packageName: A* Pathfinding Project Pro
|
||||
packageVersion: 5.3.8
|
||||
assetPath: Packages/com.arongranberg.astar/ExampleScenes~/Scenes/LocalAvoidance/Arrow.mat
|
||||
uploadId: 764484
|
Binary file not shown.
@@ -0,0 +1,110 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5de2706722ecf4e7797812f980546c1a
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 10
|
||||
mipmaps:
|
||||
mipMapMode: 1
|
||||
enableMipMap: 1
|
||||
sRGBTexture: 1
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: -1
|
||||
maxTextureSize: 1024
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: 2
|
||||
aniso: 9
|
||||
mipBias: -100
|
||||
wrapU: 0
|
||||
wrapV: 0
|
||||
wrapW: 0
|
||||
nPOTScale: 1
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 0
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 1
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 0
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 3
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 1024
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Standalone
|
||||
maxTextureSize: 1024
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID:
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
spritePackingTag:
|
||||
pSDRemoveMatte: 0
|
||||
pSDShowRemoveMatteOption: 1
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 87744
|
||||
packageName: A* Pathfinding Project Pro
|
||||
packageVersion: 5.3.8
|
||||
assetPath: Packages/com.arongranberg.astar/ExampleScenes~/Scenes/LocalAvoidance/Arrow.psd
|
||||
uploadId: 764484
|
@@ -0,0 +1,117 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 8
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Arrow2
|
||||
m_Shader: {fileID: 211, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_Parent: {fileID: 0}
|
||||
m_ModifiedSerializedProperties: 0
|
||||
m_ValidKeywords:
|
||||
- _ALPHABLEND_ON
|
||||
- _COLOROVERLAY_ON
|
||||
m_InvalidKeywords: []
|
||||
m_LightmapFlags: 0
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: 3000
|
||||
stringTagMap:
|
||||
RenderType: Transparent
|
||||
disabledShaderPasses:
|
||||
- GRABPASS
|
||||
m_LockedProperties:
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
- _BumpMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DecalTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailAlbedoMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailMask:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailNormalMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _EmissionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MainTex:
|
||||
m_Texture: {fileID: 2800000, guid: 5de2706722ecf4e7797812f980546c1a, type: 3}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MetallicGlossMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _OcclusionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _ParallaxMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Ints: []
|
||||
m_Floats:
|
||||
- _BlendOp: 0
|
||||
- _BumpScale: 1
|
||||
- _CameraFadingEnabled: 0
|
||||
- _CameraFarFadeDistance: 2
|
||||
- _CameraNearFadeDistance: 1
|
||||
- _ColorMode: 3
|
||||
- _Cull: 2
|
||||
- _Cutoff: 0.5
|
||||
- _DetailNormalMapScale: 1
|
||||
- _DistortionBlend: 0.5
|
||||
- _DistortionEnabled: 0
|
||||
- _DistortionStrength: 1
|
||||
- _DistortionStrengthScaled: 0
|
||||
- _DstBlend: 10
|
||||
- _EmissionEnabled: 0
|
||||
- _FlipbookMode: 0
|
||||
- _GlossMapScale: 1
|
||||
- _Glossiness: 0.5
|
||||
- _GlossyReflections: 1
|
||||
- _InvFade: 1
|
||||
- _LightingEnabled: 0
|
||||
- _Metallic: 0
|
||||
- _Mode: 2
|
||||
- _OcclusionStrength: 1
|
||||
- _Parallax: 0.02
|
||||
- _Shininess: 0.08769007
|
||||
- _SmoothnessTextureChannel: 0
|
||||
- _SoftParticlesEnabled: 0
|
||||
- _SoftParticlesFarFadeDistance: 1
|
||||
- _SoftParticlesNearFadeDistance: 0
|
||||
- _SpecularHighlights: 1
|
||||
- _SrcBlend: 5
|
||||
- _UVSec: 0
|
||||
- _ZWrite: 0
|
||||
m_Colors:
|
||||
- _CameraFadeParams: {r: 0, g: Infinity, b: 0, a: 0}
|
||||
- _Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _ColorAddSubDiff: {r: -1, g: 0, b: 0, a: 0}
|
||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
- _SoftParticleFadeParams: {r: 0, g: 0, b: 0, a: 0}
|
||||
- _SpecColor: {r: 0.8708022, g: 0.8708022, b: 0.8708022, a: 0}
|
||||
- _TintColor: {r: 1, g: 1, b: 1, a: 0.49411765}
|
||||
m_BuildTextureStacks: []
|
||||
--- !u!1002 &2100001
|
||||
EditorExtensionImpl:
|
||||
serializedVersion: 6
|
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 56c8a729c9a28cc509373ce53c67138b
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 87744
|
||||
packageName: A* Pathfinding Project Pro
|
||||
packageVersion: 5.3.8
|
||||
assetPath: Packages/com.arongranberg.astar/ExampleScenes~/Scenes/LocalAvoidance/Arrow2.mat
|
||||
uploadId: 764484
|
@@ -0,0 +1,129 @@
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
using Pathfinding.RVO;
|
||||
using Pathfinding.Util;
|
||||
|
||||
namespace Pathfinding.Examples {
|
||||
/// <summary>
|
||||
/// RVO Example Scene Unit Controller.
|
||||
/// Controls AIs and camera in the RVO example scene.
|
||||
/// </summary>
|
||||
[HelpURL("https://arongranberg.com/astar/documentation/stable/groupcontroller.html")]
|
||||
public class GroupController : MonoBehaviour {
|
||||
public GUIStyle selectionBox;
|
||||
public bool adjustCamera = true;
|
||||
|
||||
Vector2 start, end;
|
||||
bool wasDown = false;
|
||||
|
||||
|
||||
List<RVOExampleAgent> selection = new List<RVOExampleAgent>();
|
||||
|
||||
SimulatorBurst sim;
|
||||
|
||||
Camera cam;
|
||||
|
||||
public void Start () {
|
||||
cam = Camera.main;
|
||||
var simu = RVOSimulator.active;
|
||||
if (simu == null) {
|
||||
this.enabled = false;
|
||||
throw new System.Exception("No RVOSimulator in the scene. Please add one");
|
||||
}
|
||||
|
||||
sim = simu.GetSimulator();
|
||||
}
|
||||
|
||||
public void Update () {
|
||||
if (adjustCamera) {
|
||||
// Adjust camera
|
||||
var bounds = sim.AgentBounds;
|
||||
float max = Mathf.Max(Mathf.Max(bounds.xMax, -bounds.xMin), Mathf.Max(bounds.yMax, -bounds.yMin));
|
||||
|
||||
float hh = max / Mathf.Tan((cam.fieldOfView*Mathf.Deg2Rad/2.0f));
|
||||
float hv = max / Mathf.Tan(Mathf.Atan(Mathf.Tan(cam.fieldOfView*Mathf.Deg2Rad/2.0f)*cam.aspect));
|
||||
|
||||
var yCoord = Mathf.Max(hh, hv)*1.1f;
|
||||
yCoord = Mathf.Max(yCoord, 20);
|
||||
yCoord = Mathf.Min(yCoord, cam.farClipPlane - 1f);
|
||||
cam.transform.position = Vector3.Lerp(cam.transform.position, new Vector3(0, yCoord, 0), Time.smoothDeltaTime*2);
|
||||
}
|
||||
|
||||
if (Input.GetKey(KeyCode.A) && Input.GetKeyDown(KeyCode.Mouse0)) {
|
||||
Order();
|
||||
}
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void OnGUI () {
|
||||
if (Event.current.type == EventType.MouseUp && Event.current.button == 0 && !Input.GetKey(KeyCode.A)) {
|
||||
Select(start, end);
|
||||
wasDown = false;
|
||||
}
|
||||
|
||||
if (Event.current.type == EventType.MouseDrag && Event.current.button == 0) {
|
||||
end = Event.current.mousePosition;
|
||||
|
||||
if (!wasDown) { start = end; wasDown = true; }
|
||||
}
|
||||
|
||||
if (Input.GetKey(KeyCode.A)) wasDown = false;
|
||||
if (wasDown) {
|
||||
Rect r = Rect.MinMaxRect(Mathf.Min(start.x, end.x), Mathf.Min(start.y, end.y), Mathf.Max(start.x, end.x), Mathf.Max(start.y, end.y));
|
||||
if (r.width > 4 && r.height > 4)
|
||||
GUI.Box(r, "", selectionBox);
|
||||
}
|
||||
}
|
||||
|
||||
public void Order () {
|
||||
Ray ray = cam.ScreenPointToRay(Input.mousePosition);
|
||||
RaycastHit hit;
|
||||
|
||||
if (Physics.Raycast(ray, out hit)) {
|
||||
float radsum = 0;
|
||||
for (int i = 0; i < selection.Count; i++) radsum += selection[i].GetComponent<RVOController>().radius;
|
||||
|
||||
float radius = radsum / (Mathf.PI);
|
||||
radius *= 2f;
|
||||
|
||||
for (int i = 0; i < selection.Count; i++) {
|
||||
float deg = 2*Mathf.PI*i/selection.Count;
|
||||
Vector3 p = hit.point + new Vector3(Mathf.Cos(deg), 0, Mathf.Sin(deg))*radius;
|
||||
//Debug.DrawRay (p,Vector3.up*4,Color.cyan);
|
||||
//Debug.Break();
|
||||
selection[i].SetTarget(p);
|
||||
selection[i].SetColor(GetColor(deg));
|
||||
selection[i].RecalculatePath();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Select (Vector2 _start, Vector2 _end) {
|
||||
_start.y = Screen.height - _start.y;
|
||||
_end.y = Screen.height - _end.y;
|
||||
|
||||
Vector2 start = Vector2.Min(_start, _end);
|
||||
Vector2 end = Vector2.Max(_start, _end);
|
||||
|
||||
if ((end-start).sqrMagnitude < 4*4) return;
|
||||
|
||||
selection.Clear();
|
||||
|
||||
RVOExampleAgent[] rvo = UnityCompatibility.FindObjectsByTypeSorted<RVOExampleAgent>();
|
||||
for (int i = 0; i < rvo.Length; i++) {
|
||||
Vector2 sp = cam.WorldToScreenPoint(rvo[i].transform.position);
|
||||
if (sp.x > start.x && sp.y > start.y && sp.x < end.x && sp.y < end.y) {
|
||||
selection.Add(rvo[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Radians to degrees constant</summary>
|
||||
const float rad2Deg = 360.0f/ ((float)System.Math.PI*2);
|
||||
|
||||
/// <summary>Color from an angle</summary>
|
||||
public Color GetColor (float angle) {
|
||||
return AstarMath.HSVToRGB(angle * rad2Deg, 0.8f, 0.6f);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,14 @@
|
||||
fileFormatVersion: 2
|
||||
guid: db9dd0f9051524c2c87924ce0b79f2a6
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 87744
|
||||
packageName: A* Pathfinding Project Pro
|
||||
packageVersion: 5.3.8
|
||||
assetPath: Packages/com.arongranberg.astar/ExampleScenes~/Scenes/LocalAvoidance/GroupController.cs
|
||||
uploadId: 764484
|
@@ -0,0 +1,578 @@
|
||||
#pragma warning disable 0282 // Allows the 'partial' keyword without warnings
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
#if MODULE_ENTITIES
|
||||
using Pathfinding.RVO;
|
||||
using Unity.Jobs;
|
||||
using Unity.Mathematics;
|
||||
using Unity.Burst;
|
||||
using Unity.Collections;
|
||||
using UnityEngine.Rendering;
|
||||
using Unity.Entities;
|
||||
using Unity.Transforms;
|
||||
|
||||
namespace Pathfinding.Examples {
|
||||
using Pathfinding.ECS;
|
||||
using Pathfinding.ECS.RVO;
|
||||
using Pathfinding.Util;
|
||||
|
||||
/// <summary>
|
||||
/// Lightweight example script for simulating rvo agents.
|
||||
///
|
||||
/// This script, compared to using lots of RVOController components shows the real power of the RVO simulator when
|
||||
/// little other overhead (e.g GameObjects and pathfinding) is present.
|
||||
///
|
||||
/// With this script, I can simulate 30 000 agents at over 60 fps on my, admittedly quite beefy, machine (in a standalone build, with the local avoidance simulation running at a fixed 60 fps and using up to 14 cores of my machine).
|
||||
/// This is significantly more than one can simulate when using GameObjects for each agent.
|
||||
///
|
||||
/// This script will render the agents by generating a square for each agent combined into a single mesh with appropriate UV.
|
||||
///
|
||||
/// A few GUI buttons will be drawn by this script with which the user can change the number of agents.
|
||||
///
|
||||
/// [Open online documentation to see images]
|
||||
///
|
||||
/// Video: https://www.youtube.com/watch?v=wxzrHRIiVyk
|
||||
///
|
||||
/// See: local-avoidance (view in online documentation for working links)
|
||||
/// </summary>
|
||||
public partial class LightweightRVO : MonoBehaviour {
|
||||
/// <summary>Number of agents created at start</summary>
|
||||
public int agentCount = 100;
|
||||
|
||||
/// <summary>How large is the area in which the agents are distributed when starting the simulation</summary>
|
||||
public float exampleScale = 100;
|
||||
|
||||
|
||||
public enum RVOExampleType {
|
||||
Circle,
|
||||
Line,
|
||||
Point,
|
||||
RandomStreams,
|
||||
Crossing
|
||||
}
|
||||
|
||||
/// <summary>How the agents are distributed when starting the simulation</summary>
|
||||
public RVOExampleType type = RVOExampleType.Circle;
|
||||
|
||||
/// <summary>Agent radius</summary>
|
||||
public float radius = 3;
|
||||
|
||||
/// <summary>Max speed for an agent</summary>
|
||||
public float maxSpeed = 2;
|
||||
|
||||
/// <summary>How far in the future too look for agents</summary>
|
||||
public float agentTimeHorizon = 10;
|
||||
|
||||
[HideInInspector]
|
||||
/// <summary>How far in the future too look for obstacles</summary>
|
||||
public float obstacleTimeHorizon = 10;
|
||||
|
||||
/// <summary>Max number of neighbour agents to take into account</summary>
|
||||
public int maxNeighbours = 10;
|
||||
|
||||
/// <summary>
|
||||
/// Offset from the agent position the actual drawn postition.
|
||||
/// Used to get rid of z-buffer issues
|
||||
/// </summary>
|
||||
public Vector3 renderingOffset = Vector3.up*0.1f;
|
||||
|
||||
/// <summary>Bitmas of debugging options to enable for the agents</summary>
|
||||
public AgentDebugFlags debug;
|
||||
public Material material;
|
||||
|
||||
public void Start () {
|
||||
CreateAgents(agentCount);
|
||||
|
||||
// Create the systems and add them to their respective simulation groups
|
||||
// Normally this is handled automatically by Unity, but we use the [DisableAutoCreation] attribute
|
||||
// since these systems are only used in an example scene.
|
||||
var world = World.DefaultGameObjectInjectionWorld;
|
||||
var simulationGroup = world.GetOrCreateSystemManaged<AIMovementSystemGroup>();
|
||||
simulationGroup.AddSystemToUpdateList(world.CreateSystem<LightweightRVOControlSystem>());
|
||||
simulationGroup.AddSystemToUpdateList(world.CreateSystem<LightweightRVOMoveSystem>());
|
||||
var renderSystem = world.AddSystemManaged(new LightweightRVORenderSystem {
|
||||
material = material,
|
||||
renderingOffset = renderingOffset,
|
||||
});
|
||||
world.GetOrCreateSystemManaged<PresentationSystemGroup>().AddSystemToUpdateList(renderSystem);
|
||||
|
||||
// Annoyingly, the PresentationSystemGroup is not called when the game is paused.
|
||||
// So we need to render the mesh from a different callback, otherwise the mesh would
|
||||
// disappear when pausing the game.
|
||||
// To add additional complexity, we need different callbacks depending on if
|
||||
// we are using the built-in render pipeline or a scriptable render pipeline.
|
||||
|
||||
// Callback when rendering with the built-in render pipeline
|
||||
Camera.onPreCull += PreCull;
|
||||
// Callback when rendering with a scriptable render pipeline
|
||||
#if UNITY_2023_3_OR_NEWER
|
||||
RenderPipelineManager.beginContextRendering += OnBeginContextRendering;
|
||||
#else
|
||||
RenderPipelineManager.beginFrameRendering += OnBeginFrameRendering;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if UNITY_2023_3_OR_NEWER
|
||||
void OnBeginContextRendering (ScriptableRenderContext ctx, List<Camera> cameras) {
|
||||
for (int i = 0; i < cameras.Count; i++) PreCull(cameras[i]);
|
||||
}
|
||||
#else
|
||||
void OnBeginFrameRendering (ScriptableRenderContext ctx, Camera[] cameras) {
|
||||
for (int i = 0; i < cameras.Length; i++) PreCull(cameras[i]);
|
||||
}
|
||||
#endif
|
||||
|
||||
void PreCull (Camera camera) {
|
||||
var world = World.DefaultGameObjectInjectionWorld;
|
||||
var mesh = world.GetOrCreateSystemManaged<LightweightRVORenderSystem>().mesh;
|
||||
|
||||
// Render the mesh in the game
|
||||
Graphics.DrawMesh(mesh, Matrix4x4.identity, material, 0, camera);
|
||||
}
|
||||
|
||||
void OnDestroy () {
|
||||
#if UNITY_2023_3_OR_NEWER
|
||||
RenderPipelineManager.beginContextRendering -= OnBeginContextRendering;
|
||||
#else
|
||||
RenderPipelineManager.beginFrameRendering -= OnBeginFrameRendering;
|
||||
#endif
|
||||
Camera.onPreCull -= PreCull;
|
||||
}
|
||||
|
||||
public void OnGUI () {
|
||||
if (GUILayout.Button("2")) CreateAgents(2);
|
||||
if (GUILayout.Button("10")) CreateAgents(10);
|
||||
if (GUILayout.Button("100")) CreateAgents(100);
|
||||
if (GUILayout.Button("500")) CreateAgents(500);
|
||||
if (GUILayout.Button("1000")) CreateAgents(1000);
|
||||
if (GUILayout.Button("5000")) CreateAgents(5000);
|
||||
if (GUILayout.Button("10000")) CreateAgents(10000);
|
||||
if (GUILayout.Button("20000")) CreateAgents(20000);
|
||||
if (GUILayout.Button("30000")) CreateAgents(30000);
|
||||
|
||||
GUILayout.Space(5);
|
||||
|
||||
if (GUILayout.Button("Random Streams")) {
|
||||
type = RVOExampleType.RandomStreams;
|
||||
CreateAgents(agentCount);
|
||||
}
|
||||
|
||||
if (GUILayout.Button("Line")) {
|
||||
type = RVOExampleType.Line;
|
||||
CreateAgents(Mathf.Min(agentCount, 100));
|
||||
}
|
||||
|
||||
if (GUILayout.Button("Circle")) {
|
||||
type = RVOExampleType.Circle;
|
||||
CreateAgents(agentCount);
|
||||
}
|
||||
|
||||
if (GUILayout.Button("Point")) {
|
||||
type = RVOExampleType.Point;
|
||||
CreateAgents(agentCount);
|
||||
}
|
||||
|
||||
if (GUILayout.Button("Crossing")) {
|
||||
type = RVOExampleType.Crossing;
|
||||
CreateAgents(agentCount);
|
||||
}
|
||||
}
|
||||
|
||||
public void Update () {
|
||||
var world = World.DefaultGameObjectInjectionWorld;
|
||||
var system = world.GetOrCreateSystem<LightweightRVOControlSystem>();
|
||||
world.Unmanaged.GetUnsafeSystemRef<LightweightRVOControlSystem>(system).debug = debug;
|
||||
}
|
||||
|
||||
private float uniformDistance (float radius) {
|
||||
float v = UnityEngine.Random.value + UnityEngine.Random.value;
|
||||
|
||||
if (v > 1) return radius * (2-v);
|
||||
else return radius * v;
|
||||
}
|
||||
|
||||
/// <summary>Some agent data used in the lightweight rvo example scene</summary>
|
||||
public struct LightweightAgentData : IComponentData {
|
||||
public Color32 color;
|
||||
public float maxSpeed;
|
||||
}
|
||||
|
||||
/// <summary>Create a single agent entity</summary>
|
||||
Entity CreateAgent (EntityArchetype archetype, EntityCommandBuffer buffer, Vector3 position, Vector3 destination, Color color, float priority = 0.5f) {
|
||||
var entity = buffer.CreateEntity(archetype);
|
||||
buffer.AddComponent<LocalTransform>(entity, LocalTransform.FromPosition(position));
|
||||
buffer.AddComponent<DestinationPoint>(entity, new DestinationPoint { destination = destination });
|
||||
buffer.AddComponent<RVOAgent>(entity, new RVOAgent {
|
||||
agentTimeHorizon = agentTimeHorizon,
|
||||
obstacleTimeHorizon = obstacleTimeHorizon,
|
||||
maxNeighbours = maxNeighbours,
|
||||
layer = RVOLayer.DefaultAgent,
|
||||
collidesWith = (RVOLayer)(-1),
|
||||
priority = priority,
|
||||
priorityMultiplier = 1,
|
||||
flowFollowingStrength = 0,
|
||||
debug = AgentDebugFlags.Nothing,
|
||||
locked = false
|
||||
});
|
||||
buffer.AddComponent<AgentMovementPlane>(entity, new AgentMovementPlane { value = new NativeMovementPlane(quaternion.identity) });
|
||||
buffer.AddComponent<AgentCylinderShape>(entity, new AgentCylinderShape { radius = radius, height = 1.0f });
|
||||
buffer.AddComponent<LightweightAgentData>(entity, new LightweightAgentData {
|
||||
color = (Color32)color,
|
||||
maxSpeed = maxSpeed
|
||||
});
|
||||
return entity;
|
||||
}
|
||||
|
||||
/// <summary>Create a number of agents in circle and restart simulation</summary>
|
||||
public void CreateAgents (int num) {
|
||||
this.agentCount = num;
|
||||
var world = World.DefaultGameObjectInjectionWorld;
|
||||
var entityManager = world.EntityManager;
|
||||
var archetype = entityManager.CreateArchetype(
|
||||
typeof(LocalTransform),
|
||||
typeof(LocalToWorld),
|
||||
typeof(AgentCylinderShape),
|
||||
typeof(ResolvedMovement),
|
||||
typeof(DestinationPoint),
|
||||
typeof(MovementControl),
|
||||
typeof(RVOAgent),
|
||||
typeof(AgentMovementPlane),
|
||||
typeof(LightweightAgentData),
|
||||
typeof(SimulateMovement),
|
||||
typeof(SimulateMovementRepair),
|
||||
typeof(SimulateMovementControl),
|
||||
typeof(SimulateMovementFinalize)
|
||||
);
|
||||
|
||||
var buffer = new EntityCommandBuffer(Allocator.Temp);
|
||||
var existingEntities = entityManager.CreateEntityQuery(typeof(LightweightAgentData));
|
||||
|
||||
#if MODULE_ENTITIES_1_0_8_OR_NEWER
|
||||
buffer.DestroyEntity(existingEntities, EntityQueryCaptureMode.AtPlayback);
|
||||
#else
|
||||
buffer.DestroyEntity(existingEntities);
|
||||
#endif
|
||||
|
||||
if (type == RVOExampleType.Circle) {
|
||||
float agentArea = agentCount * radius * radius * Mathf.PI;
|
||||
const float EmptyFraction = 0.7f;
|
||||
const float PackingDensity = 0.9f;
|
||||
float innerCircleRadius = Mathf.Sqrt(agentArea/(Mathf.PI*(1-EmptyFraction*EmptyFraction)));
|
||||
float outerCircleRadius = Mathf.Sqrt(innerCircleRadius*innerCircleRadius + agentCount*radius*radius/PackingDensity);
|
||||
|
||||
for (int i = 0; i < agentCount; i++) {
|
||||
Vector3 pos = new Vector3(Mathf.Cos(i * Mathf.PI * 2.0f / agentCount), 0, Mathf.Sin(i * Mathf.PI * 2.0f / agentCount)) * math.lerp(innerCircleRadius, outerCircleRadius, UnityEngine.Random.value);
|
||||
var destination = new float3(-pos.x, 0, -pos.z);
|
||||
var color = AstarMath.HSVToRGB(i * 360.0f / agentCount, 0.8f, 0.6f);
|
||||
CreateAgent(archetype, buffer, pos, destination, color);
|
||||
}
|
||||
} else if (type == RVOExampleType.Line) {
|
||||
for (int i = 0; i < agentCount; i++) {
|
||||
Vector3 pos = new Vector3((i % 2 == 0 ? 1 : -1) * exampleScale, 0, (i / 2) * radius * 2.5f);
|
||||
CreateAgent(archetype, buffer, pos, new float3(-pos.x, 0, pos.z), i % 2 == 0 ? Color.red : Color.blue);
|
||||
}
|
||||
} else if (type == RVOExampleType.Point) {
|
||||
for (int i = 0; i < agentCount; i++) {
|
||||
Vector3 pos = new Vector3(Mathf.Cos(i * Mathf.PI * 2.0f / agentCount), 0, Mathf.Sin(i * Mathf.PI * 2.0f / agentCount)) * exampleScale;
|
||||
CreateAgent(archetype, buffer, pos, new float3(0, 0, 0), AstarMath.HSVToRGB(i * 360.0f / agentCount, 0.8f, 0.6f));
|
||||
}
|
||||
} else if (type == RVOExampleType.RandomStreams) {
|
||||
float circleRad = Mathf.Sqrt(agentCount * radius * radius * 4 / Mathf.PI) * exampleScale * 0.05f;
|
||||
|
||||
for (int i = 0; i < agentCount; i++) {
|
||||
float angle = UnityEngine.Random.value * Mathf.PI * 2.0f;
|
||||
float targetAngle = UnityEngine.Random.value * Mathf.PI * 2.0f;
|
||||
Vector3 pos = new Vector3(Mathf.Cos(angle), 0, Mathf.Sin(angle)) * uniformDistance(circleRad);
|
||||
var destination = new float3(Mathf.Cos(targetAngle), 0, Mathf.Sin(targetAngle)) * uniformDistance(circleRad);
|
||||
var color = AstarMath.HSVToRGB(targetAngle * Mathf.Rad2Deg, 0.8f, 0.6f);
|
||||
CreateAgent(archetype, buffer, pos, destination, color);
|
||||
}
|
||||
} else if (type == RVOExampleType.Crossing) {
|
||||
float distanceBetweenGroups = exampleScale * radius * 0.5f;
|
||||
int directions = (int)Mathf.Sqrt(agentCount / 25f);
|
||||
directions = Mathf.Max(directions, 2);
|
||||
|
||||
const int AgentsPerDistance = 10;
|
||||
for (int i = 0; i < agentCount; i++) {
|
||||
float angle = ((i % directions)/(float)directions) * Mathf.PI * 2.0f;
|
||||
var dist = distanceBetweenGroups * ((i/(directions*AgentsPerDistance) + 1) + 0.3f*UnityEngine.Random.value);
|
||||
Vector3 pos = new Vector3(Mathf.Cos(angle), 0, Mathf.Sin(angle)) * dist;
|
||||
var destination = math.normalizesafe(new float3(-pos.x, 0, -pos.z)) * distanceBetweenGroups * 3;
|
||||
var color = AstarMath.HSVToRGB(angle * Mathf.Rad2Deg, 0.8f, 0.6f);
|
||||
CreateAgent(archetype, buffer, pos, destination, color, priority: (i % directions) == 0 ? 1 : 0.01f);
|
||||
}
|
||||
}
|
||||
|
||||
buffer.Playback(entityManager);
|
||||
}
|
||||
|
||||
/// <summary>Lightweight example system for moving agents</summary>
|
||||
[UpdateAfter(typeof(RVOSystem))]
|
||||
[UpdateInGroup(typeof(AIMovementSystemGroup))]
|
||||
[DisableAutoCreation]
|
||||
public partial struct LightweightRVOMoveSystem : ISystem {
|
||||
EntityQuery entityQuery;
|
||||
|
||||
public void OnCreate (ref SystemState state) {
|
||||
entityQuery = state.GetEntityQuery(
|
||||
ComponentType.ReadWrite<LocalTransform>(),
|
||||
ComponentType.ReadOnly<AgentMovementPlane>(),
|
||||
ComponentType.ReadOnly<ResolvedMovement>()
|
||||
);
|
||||
}
|
||||
|
||||
public void OnUpdate (ref SystemState state) {
|
||||
state.Dependency = new JobMoveAgents { deltaTime = SystemAPI.Time.DeltaTime }.ScheduleParallel(entityQuery, state.Dependency);
|
||||
}
|
||||
|
||||
[BurstCompile]
|
||||
partial struct JobMoveAgents : IJobEntity {
|
||||
public float deltaTime;
|
||||
|
||||
public void Execute (ref LocalTransform transform, in AgentMovementPlane movementPlane, in ResolvedMovement resolvedMovement) {
|
||||
transform.Position += Pathfinding.ECS.JobMoveAgent.MoveWithoutGravity(ref transform, in resolvedMovement, in movementPlane, deltaTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Lightweight example system for controlling and rendering RVO agents.
|
||||
///
|
||||
/// This system is not intended to be used for anything other than the RVO example scene, and perhaps for reference for a curious reader.
|
||||
///
|
||||
/// It also relies on the <see cref="LightweightRVOMoveSystem"/> and <see cref="RVOSystem"/>.
|
||||
/// </summary>
|
||||
[UpdateBefore(typeof(RVOSystem))]
|
||||
[UpdateInGroup(typeof(AIMovementSystemGroup))]
|
||||
[DisableAutoCreation]
|
||||
public partial struct LightweightRVOControlSystem : ISystem {
|
||||
/// <summary>Determines what kind of debug info the RVO system should render as gizmos</summary>
|
||||
public AgentDebugFlags debug;
|
||||
EntityQuery entityQueryDirection;
|
||||
EntityQuery entityQueryControl;
|
||||
|
||||
public void OnCreate (ref SystemState state) {
|
||||
entityQueryDirection = state.GetEntityQuery(
|
||||
ComponentType.ReadWrite<LocalTransform>(),
|
||||
ComponentType.ReadOnly<AgentCylinderShape>(),
|
||||
ComponentType.ReadOnly<AgentMovementPlane>(),
|
||||
ComponentType.ReadOnly<MovementControl>(),
|
||||
ComponentType.ReadOnly<ResolvedMovement>()
|
||||
);
|
||||
entityQueryControl = state.GetEntityQuery(
|
||||
ComponentType.ReadOnly<LightweightAgentData>(),
|
||||
ComponentType.ReadOnly<DestinationPoint>(),
|
||||
ComponentType.ReadWrite<RVOAgent>(),
|
||||
ComponentType.ReadWrite<MovementControl>()
|
||||
);
|
||||
}
|
||||
|
||||
public void OnUpdate (ref SystemState state) {
|
||||
state.Dependency = new AlignAgentWithMovementDirectionJob {
|
||||
deltaTime = SystemAPI.Time.DeltaTime,
|
||||
rotationSpeed = 5,
|
||||
}.ScheduleParallel(entityQueryDirection, state.Dependency);
|
||||
|
||||
state.Dependency = new JobControlAgents {
|
||||
deltaTime = SystemAPI.Time.DeltaTime,
|
||||
debug = debug,
|
||||
}.Schedule(entityQueryControl, state.Dependency);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Job to set the direction each agent wants to move in.
|
||||
///
|
||||
/// The <see cref="RVOSystem"/> will then try to move the agent in that direction, but taking care to avoid other agents and obstacles.
|
||||
/// </summary>
|
||||
[BurstCompile]
|
||||
public partial struct JobControlAgents : IJobEntity {
|
||||
public float deltaTime;
|
||||
public AgentDebugFlags debug;
|
||||
|
||||
public void Execute (in LightweightAgentData agentData, in DestinationPoint destination, ref RVOAgent rvoAgent, ref MovementControl movementControl, [EntityIndexInQuery] int index) {
|
||||
movementControl = new MovementControl {
|
||||
// This is the point the agent will try to move towards
|
||||
targetPoint = destination.destination,
|
||||
endOfPath = destination.destination,
|
||||
speed = agentData.maxSpeed,
|
||||
// Allow the agent to move slightly faster than its desired speed if necessary
|
||||
maxSpeed = agentData.maxSpeed * 1.1f,
|
||||
// We don't have a graph, so this field is not relevant
|
||||
hierarchicalNodeIndex = -1,
|
||||
targetRotation = 0,
|
||||
targetRotationOffset = 0,
|
||||
rotationSpeed = 0,
|
||||
overrideLocalAvoidance = false,
|
||||
};
|
||||
|
||||
if (index == 0) {
|
||||
// Show most debug info only for the first agent, to reduce clutter
|
||||
rvoAgent.debug = debug;
|
||||
} else {
|
||||
rvoAgent.debug = debug & AgentDebugFlags.ReachedState;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Job to update each agent's position and rotation based on its movement direction</summary>
|
||||
[BurstCompile(FloatMode = FloatMode.Fast)]
|
||||
public partial struct AlignAgentWithMovementDirectionJob : IJobEntity {
|
||||
public float deltaTime;
|
||||
public float rotationSpeed;
|
||||
|
||||
public void Execute (ref LocalTransform transform, in AgentCylinderShape shape, in AgentMovementPlane movementPlane, in MovementControl movementControl, in ResolvedMovement resolvedMovement) {
|
||||
if (resolvedMovement.speed > shape.radius*0.01f) {
|
||||
var speedFraction = math.sqrt(math.clamp(resolvedMovement.speed / movementControl.maxSpeed, 0, 1));
|
||||
// If the agent is moving, align it with the movement direction
|
||||
var actualDirection = movementPlane.value.ToPlane(resolvedMovement.targetPoint - transform.Position);
|
||||
var actualAngle = math.atan2(actualDirection.y, actualDirection.x) - math.PI*0.5f;
|
||||
var targetRotation = movementPlane.value.ToWorldRotation(actualAngle);
|
||||
transform.Rotation = math.slerp(transform.Rotation, targetRotation, deltaTime*speedFraction*rotationSpeed);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// System to render RVO agents on a mesh.
|
||||
///
|
||||
/// The system does not do any rendering itself, but only writes to the <see cref="mesh"/> field.
|
||||
/// </summary>
|
||||
[DisableAutoCreation]
|
||||
public partial class LightweightRVORenderSystem : SystemBase {
|
||||
/// <summary>Mesh for rendering</summary>
|
||||
public Mesh mesh;
|
||||
/// <summary>Material for rendering</summary>
|
||||
public Material material;
|
||||
/// <summary>Offset with which to render the mesh from the agent's original positions</summary>
|
||||
public Vector3 renderingOffset;
|
||||
|
||||
EntityQuery entityQuery;
|
||||
|
||||
protected override void OnCreate () {
|
||||
mesh = new Mesh {
|
||||
name = "RVO Agents",
|
||||
};
|
||||
entityQuery = GetEntityQuery(
|
||||
ComponentType.ReadOnly<LocalTransform>(),
|
||||
ComponentType.ReadOnly<LightweightAgentData>(),
|
||||
ComponentType.ReadOnly<DestinationPoint>(),
|
||||
ComponentType.ReadOnly<RVOAgent>(),
|
||||
ComponentType.ReadOnly<AgentCylinderShape>()
|
||||
);
|
||||
}
|
||||
|
||||
protected override void OnDestroy () {
|
||||
Mesh.Destroy(mesh);
|
||||
}
|
||||
|
||||
protected override void OnUpdate () {
|
||||
var agentCount = entityQuery.CalculateEntityCount();
|
||||
var vertexCount = agentCount*4;
|
||||
var indexCount = agentCount*6;
|
||||
var vertices = CollectionHelper.CreateNativeArray<Vertex>(vertexCount, WorldUpdateAllocator);
|
||||
var tris = CollectionHelper.CreateNativeArray<int>(indexCount, WorldUpdateAllocator);
|
||||
Dependency = new JobGenerateMesh {
|
||||
verts = vertices,
|
||||
tris = tris,
|
||||
renderingOffset = renderingOffset
|
||||
}.Schedule(entityQuery, Dependency);
|
||||
|
||||
// Specify the layout of each vertex. This should match the Vertex struct
|
||||
var layout = new[] {
|
||||
new VertexAttributeDescriptor(VertexAttribute.Position, VertexAttributeFormat.Float32, 3),
|
||||
new VertexAttributeDescriptor(VertexAttribute.Color, VertexAttributeFormat.UNorm8, 4),
|
||||
new VertexAttributeDescriptor(VertexAttribute.TexCoord0, VertexAttributeFormat.Float32, 2),
|
||||
};
|
||||
mesh.SetVertexBufferParams(vertexCount, layout);
|
||||
// To allow for more than ≈16k agents we need to use a 32 bit format for the mesh
|
||||
mesh.SetIndexBufferParams(indexCount, IndexFormat.UInt32);
|
||||
|
||||
// Wait for the JobGenerateMesh job to complete before we try to use the mesh data
|
||||
Dependency.Complete();
|
||||
|
||||
// Set the vertex and index data
|
||||
mesh.SetVertexBufferData(vertices, 0, 0, vertices.Length);
|
||||
mesh.SetIndexBufferData(tris, 0, 0, tris.Length);
|
||||
|
||||
mesh.subMeshCount = 1;
|
||||
mesh.SetSubMesh(0, new SubMeshDescriptor(0, tris.Length, MeshTopology.Triangles), MeshUpdateFlags.DontRecalculateBounds);
|
||||
// SetSubMesh doesn't seem to update the bounds properly for some reason, so we do it manually instead
|
||||
mesh.RecalculateBounds();
|
||||
}
|
||||
|
||||
[System.Runtime.InteropServices.StructLayout(System.Runtime.InteropServices.LayoutKind.Sequential)]
|
||||
public struct Vertex {
|
||||
public float3 position;
|
||||
public Color32 color;
|
||||
public float2 uv;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Generates a simple mesh for rendering the agents.
|
||||
/// Each agent is a quad rotated and positioned to align with the agent.
|
||||
/// </summary>
|
||||
[BurstCompile(FloatMode = FloatMode.Fast)]
|
||||
public partial struct JobGenerateMesh : IJobEntity {
|
||||
[WriteOnly] public NativeArray<Vertex> verts;
|
||||
[WriteOnly] public NativeArray<int> tris;
|
||||
|
||||
public Vector3 renderingOffset;
|
||||
|
||||
public void Execute (in LocalTransform transform, in LightweightAgentData agentData, in AgentCylinderShape shape, [EntityIndexInQuery] int entityIndex) {
|
||||
// Create a square with the "forward" direction along the agent's velocity
|
||||
float3 forward = transform.Forward() * shape.radius;
|
||||
if (math.all(forward == 0)) forward = new float3(0, 0, shape.radius);
|
||||
float3 right = math.cross(new float3(0, 1, 0), forward);
|
||||
float3 orig = transform.Position + (float3)renderingOffset;
|
||||
|
||||
int vc = 4*entityIndex;
|
||||
int tc = 2*3*entityIndex;
|
||||
|
||||
Color32 color = agentData.color;
|
||||
verts[vc+0] = new Vertex {
|
||||
position = (orig + forward - right),
|
||||
uv = new float2(0, 1),
|
||||
color = color,
|
||||
};
|
||||
|
||||
verts[vc+1] = new Vertex {
|
||||
position = (orig + forward + right),
|
||||
uv = new float2(1, 1),
|
||||
color = color,
|
||||
};
|
||||
|
||||
verts[vc+2] = new Vertex {
|
||||
position = (orig - forward + right),
|
||||
uv = new float2(1, 0),
|
||||
color = color,
|
||||
};
|
||||
|
||||
verts[vc+3] = new Vertex {
|
||||
position = (orig - forward - right),
|
||||
uv = new float2(0, 0),
|
||||
color = color,
|
||||
};
|
||||
|
||||
tris[tc+0] = (vc + 0);
|
||||
tris[tc+1] = (vc + 1);
|
||||
tris[tc+2] = (vc + 2);
|
||||
|
||||
tris[tc+3] = (vc + 0);
|
||||
tris[tc+4] = (vc + 2);
|
||||
tris[tc+5] = (vc + 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
namespace Pathfinding.Examples {
|
||||
[HelpURL("https://arongranberg.com/astar/documentation/stable/lightweightrvo.html")]
|
||||
public class LightweightRVO : MonoBehaviour {
|
||||
public void Start () {
|
||||
Debug.LogError("Lightweight RVO example script requires the entities package to be installed.");
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
@@ -0,0 +1,14 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cd22169e5a88449fca9e480b59dae980
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 87744
|
||||
packageName: A* Pathfinding Project Pro
|
||||
packageVersion: 5.3.8
|
||||
assetPath: Packages/com.arongranberg.astar/ExampleScenes~/Scenes/LocalAvoidance/LightweightRVO.cs
|
||||
uploadId: 764484
|
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a72d110e16b2e46b58db5ecb9717f37f
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 87744
|
||||
packageName: A* Pathfinding Project Pro
|
||||
packageVersion: 5.3.8
|
||||
assetPath: Packages/com.arongranberg.astar/ExampleScenes~/Scenes/LocalAvoidance/LocalAvoidance.unity
|
||||
uploadId: 764484
|
@@ -0,0 +1,889 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!29 &1
|
||||
OcclusionCullingSettings:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 2
|
||||
m_OcclusionBakeSettings:
|
||||
smallestOccluder: 5
|
||||
smallestHole: 0.25
|
||||
backfaceThreshold: 100
|
||||
m_SceneGUID: 00000000000000000000000000000000
|
||||
m_OcclusionCullingData: {fileID: 0}
|
||||
--- !u!104 &2
|
||||
RenderSettings:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 10
|
||||
m_Fog: 0
|
||||
m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
|
||||
m_FogMode: 3
|
||||
m_FogDensity: 0.01
|
||||
m_LinearFogStart: 0
|
||||
m_LinearFogEnd: 300
|
||||
m_AmbientSkyColor: {r: 0.2, g: 0.2, b: 0.2, a: 1}
|
||||
m_AmbientEquatorColor: {r: 0.2, g: 0.2, b: 0.2, a: 1}
|
||||
m_AmbientGroundColor: {r: 0.2, g: 0.2, b: 0.2, a: 1}
|
||||
m_AmbientIntensity: 1
|
||||
m_AmbientMode: 3
|
||||
m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1}
|
||||
m_SkyboxMaterial: {fileID: 0}
|
||||
m_HaloStrength: 0.5
|
||||
m_FlareStrength: 1
|
||||
m_FlareFadeSpeed: 3
|
||||
m_HaloTexture: {fileID: 0}
|
||||
m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0}
|
||||
m_DefaultReflectionMode: 0
|
||||
m_DefaultReflectionResolution: 128
|
||||
m_ReflectionBounces: 1
|
||||
m_ReflectionIntensity: 1
|
||||
m_CustomReflection: {fileID: 0}
|
||||
m_Sun: {fileID: 0}
|
||||
m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
m_UseRadianceAmbientProbe: 0
|
||||
--- !u!157 &4
|
||||
LightmapSettings:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 12
|
||||
m_GISettings:
|
||||
serializedVersion: 2
|
||||
m_BounceScale: 1
|
||||
m_IndirectOutputScale: 1
|
||||
m_AlbedoBoost: 1
|
||||
m_EnvironmentLightingMode: 0
|
||||
m_EnableBakedLightmaps: 1
|
||||
m_EnableRealtimeLightmaps: 0
|
||||
m_LightmapEditorSettings:
|
||||
serializedVersion: 12
|
||||
m_Resolution: 1
|
||||
m_BakeResolution: 50
|
||||
m_AtlasSize: 1024
|
||||
m_AO: 0
|
||||
m_AOMaxDistance: 1
|
||||
m_CompAOExponent: 0
|
||||
m_CompAOExponentDirect: 0
|
||||
m_ExtractAmbientOcclusion: 0
|
||||
m_Padding: 2
|
||||
m_LightmapParameters: {fileID: 0}
|
||||
m_LightmapsBakeMode: 1
|
||||
m_TextureCompression: 0
|
||||
m_ReflectionCompression: 2
|
||||
m_MixedBakeMode: 1
|
||||
m_BakeBackend: 0
|
||||
m_PVRSampling: 1
|
||||
m_PVRDirectSampleCount: 32
|
||||
m_PVRSampleCount: 500
|
||||
m_PVRBounces: 2
|
||||
m_PVREnvironmentSampleCount: 500
|
||||
m_PVREnvironmentReferencePointCount: 2048
|
||||
m_PVRFilteringMode: 0
|
||||
m_PVRDenoiserTypeDirect: 0
|
||||
m_PVRDenoiserTypeIndirect: 0
|
||||
m_PVRDenoiserTypeAO: 0
|
||||
m_PVRFilterTypeDirect: 0
|
||||
m_PVRFilterTypeIndirect: 0
|
||||
m_PVRFilterTypeAO: 0
|
||||
m_PVREnvironmentMIS: 0
|
||||
m_PVRCulling: 1
|
||||
m_PVRFilteringGaussRadiusDirect: 1
|
||||
m_PVRFilteringGaussRadiusIndirect: 5
|
||||
m_PVRFilteringGaussRadiusAO: 2
|
||||
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
|
||||
m_PVRFilteringAtrousPositionSigmaIndirect: 2
|
||||
m_PVRFilteringAtrousPositionSigmaAO: 1
|
||||
m_ExportTrainingData: 0
|
||||
m_TrainingDataDestination: TrainingData
|
||||
m_LightProbeSampleCountMultiplier: 4
|
||||
m_LightingDataAsset: {fileID: 0}
|
||||
m_LightingSettings: {fileID: 4890085278179872738, guid: 4dbab546d071f2be28c7f23a07f95a6b,
|
||||
type: 2}
|
||||
--- !u!196 &5
|
||||
NavMeshSettings:
|
||||
serializedVersion: 2
|
||||
m_ObjectHideFlags: 0
|
||||
m_BuildSettings:
|
||||
serializedVersion: 3
|
||||
agentTypeID: 0
|
||||
agentRadius: 0.5
|
||||
agentHeight: 2
|
||||
agentSlope: 45
|
||||
agentClimb: 0.4
|
||||
ledgeDropHeight: 0
|
||||
maxJumpAcrossDistance: 0
|
||||
minRegionArea: 2
|
||||
manualCellSize: 0
|
||||
cellSize: 0.16666666
|
||||
manualTileSize: 0
|
||||
tileSize: 256
|
||||
buildHeightMesh: 0
|
||||
maxJobWorkers: 0
|
||||
preserveTilesOutsideBounds: 0
|
||||
debug:
|
||||
m_Flags: 0
|
||||
m_NavMeshData: {fileID: 0}
|
||||
--- !u!1 &157608482
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 157608483}
|
||||
- component: {fileID: 157608487}
|
||||
- component: {fileID: 157608486}
|
||||
m_Layer: 0
|
||||
m_Name: RVOSimulator
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &157608483
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 157608482}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &157608486
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 157608482}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: cd22169e5a88449fca9e480b59dae980, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
agentCount: 300
|
||||
exampleScale: 80
|
||||
type: 0
|
||||
radius: 1.5
|
||||
maxSpeed: 5
|
||||
agentTimeHorizon: 2
|
||||
obstacleTimeHorizon: 10
|
||||
maxNeighbours: 10
|
||||
renderingOffset: {x: 0, y: 1, z: 0}
|
||||
debug: 0
|
||||
material: {fileID: 2100000, guid: 6ac95c099f0e2ad4d90aa8dbf92a6f5d, type: 2}
|
||||
--- !u!114 &157608487
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 157608482}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 1764de1de43cc4d19af52679d3eaae06, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
version: 1073741824
|
||||
desiredSimulationFPS: 20
|
||||
workerThreads: -1
|
||||
doubleBuffering: 0
|
||||
hardCollisions: 1
|
||||
symmetryBreakingBias: 0.1
|
||||
movementPlane: 0
|
||||
useNavmeshAsObstacle: 1
|
||||
drawQuadtree: 0
|
||||
--- !u!1 &581733579
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 581733580}
|
||||
- component: {fileID: 581733583}
|
||||
- component: {fileID: 581733582}
|
||||
- component: {fileID: 581733581}
|
||||
m_Layer: 0
|
||||
m_Name: Description
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &581733580
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 581733579}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 1192988233}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 1, y: 1}
|
||||
m_AnchorMax: {x: 1, y: 1}
|
||||
m_AnchoredPosition: {x: -10, y: -10}
|
||||
m_SizeDelta: {x: 400, y: 300}
|
||||
m_Pivot: {x: 1, y: 1}
|
||||
--- !u!114 &581733581
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 581733579}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: cfabb0440166ab443bba8876756fdfa9, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_EffectColor: {r: 0, g: 0, b: 0, a: 0.5}
|
||||
m_EffectDistance: {x: 1, y: -1}
|
||||
m_UseGraphicAlpha: 1
|
||||
--- !u!114 &581733582
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 581733579}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_RaycastTarget: 1
|
||||
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_Maskable: 1
|
||||
m_OnCullStateChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_FontData:
|
||||
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
|
||||
m_FontSize: 14
|
||||
m_FontStyle: 0
|
||||
m_BestFit: 0
|
||||
m_MinSize: 10
|
||||
m_MaxSize: 40
|
||||
m_Alignment: 2
|
||||
m_AlignByGeometry: 0
|
||||
m_RichText: 1
|
||||
m_HorizontalOverflow: 0
|
||||
m_VerticalOverflow: 0
|
||||
m_LineSpacing: 1
|
||||
m_Text: 'Local Avoidance Example
|
||||
|
||||
Units are rendered on a
|
||||
|
||||
single mesh
|
||||
for performance
|
||||
|
||||
No pathfinding is done in this example'
|
||||
--- !u!222 &581733583
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 581733579}
|
||||
m_CullTransparentMesh: 0
|
||||
--- !u!1 &687969035
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 687969039}
|
||||
- component: {fileID: 687969038}
|
||||
- component: {fileID: 687969037}
|
||||
- component: {fileID: 687969036}
|
||||
m_Layer: 0
|
||||
m_Name: Plane
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 4294967295
|
||||
m_IsActive: 1
|
||||
--- !u!23 &687969036
|
||||
MeshRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 687969035}
|
||||
m_Enabled: 1
|
||||
m_CastShadows: 1
|
||||
m_ReceiveShadows: 1
|
||||
m_DynamicOccludee: 1
|
||||
m_StaticShadowCaster: 0
|
||||
m_MotionVectors: 1
|
||||
m_LightProbeUsage: 0
|
||||
m_ReflectionProbeUsage: 1
|
||||
m_RayTracingMode: 2
|
||||
m_RayTraceProcedural: 0
|
||||
m_RayTracingAccelStructBuildFlagsOverride: 0
|
||||
m_RayTracingAccelStructBuildFlags: 1
|
||||
m_RenderingLayerMask: 1
|
||||
m_RendererPriority: 0
|
||||
m_Materials:
|
||||
- {fileID: 2100000, guid: 8f4d5503fdeab441e8c6c041504cf535, type: 2}
|
||||
m_StaticBatchInfo:
|
||||
firstSubMesh: 0
|
||||
subMeshCount: 0
|
||||
m_StaticBatchRoot: {fileID: 0}
|
||||
m_ProbeAnchor: {fileID: 0}
|
||||
m_LightProbeVolumeOverride: {fileID: 0}
|
||||
m_ScaleInLightmap: 0.8
|
||||
m_ReceiveGI: 1
|
||||
m_PreserveUVs: 0
|
||||
m_IgnoreNormalsForChartDetection: 0
|
||||
m_ImportantGI: 0
|
||||
m_StitchLightmapSeams: 0
|
||||
m_SelectedEditorRenderState: 3
|
||||
m_MinimumChartSize: 4
|
||||
m_AutoUVMaxDistance: 0.5
|
||||
m_AutoUVMaxAngle: 89
|
||||
m_LightmapParameters: {fileID: 0}
|
||||
m_SortingLayerID: 0
|
||||
m_SortingLayer: 0
|
||||
m_SortingOrder: 0
|
||||
m_AdditionalVertexStreams: {fileID: 0}
|
||||
--- !u!64 &687969037
|
||||
MeshCollider:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 687969035}
|
||||
m_Material: {fileID: 0}
|
||||
m_IncludeLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 0
|
||||
m_ExcludeLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 0
|
||||
m_LayerOverridePriority: 0
|
||||
m_IsTrigger: 0
|
||||
m_ProvidesContacts: 0
|
||||
m_Enabled: 1
|
||||
serializedVersion: 5
|
||||
m_Convex: 0
|
||||
m_CookingOptions: 30
|
||||
m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0}
|
||||
--- !u!33 &687969038
|
||||
MeshFilter:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 687969035}
|
||||
m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0}
|
||||
--- !u!4 &687969039
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 687969035}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: -0.1, z: 0}
|
||||
m_LocalScale: {x: 62.87725, y: 1, z: 62.87725}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &910242485
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 910242486}
|
||||
- component: {fileID: 910242488}
|
||||
- component: {fileID: 910242489}
|
||||
- component: {fileID: 910242487}
|
||||
m_Layer: 0
|
||||
m_Name: Plane
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 4294967295
|
||||
m_IsActive: 1
|
||||
--- !u!4 &910242486
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 910242485}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: -0.2, z: 0}
|
||||
m_LocalScale: {x: 62.877247, y: 1, z: 62.87725}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!23 &910242487
|
||||
MeshRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 910242485}
|
||||
m_Enabled: 1
|
||||
m_CastShadows: 1
|
||||
m_ReceiveShadows: 1
|
||||
m_DynamicOccludee: 1
|
||||
m_StaticShadowCaster: 0
|
||||
m_MotionVectors: 1
|
||||
m_LightProbeUsage: 0
|
||||
m_ReflectionProbeUsage: 1
|
||||
m_RayTracingMode: 2
|
||||
m_RayTraceProcedural: 0
|
||||
m_RayTracingAccelStructBuildFlagsOverride: 0
|
||||
m_RayTracingAccelStructBuildFlags: 1
|
||||
m_RenderingLayerMask: 1
|
||||
m_RendererPriority: 0
|
||||
m_Materials:
|
||||
- {fileID: 2100000, guid: b71b71b0a1f9a48768a27ca6eefcfbdf, type: 2}
|
||||
m_StaticBatchInfo:
|
||||
firstSubMesh: 0
|
||||
subMeshCount: 0
|
||||
m_StaticBatchRoot: {fileID: 0}
|
||||
m_ProbeAnchor: {fileID: 0}
|
||||
m_LightProbeVolumeOverride: {fileID: 0}
|
||||
m_ScaleInLightmap: 0.8
|
||||
m_ReceiveGI: 1
|
||||
m_PreserveUVs: 0
|
||||
m_IgnoreNormalsForChartDetection: 0
|
||||
m_ImportantGI: 0
|
||||
m_StitchLightmapSeams: 0
|
||||
m_SelectedEditorRenderState: 3
|
||||
m_MinimumChartSize: 4
|
||||
m_AutoUVMaxDistance: 0.5
|
||||
m_AutoUVMaxAngle: 89
|
||||
m_LightmapParameters: {fileID: 0}
|
||||
m_SortingLayerID: 0
|
||||
m_SortingLayer: 0
|
||||
m_SortingOrder: 0
|
||||
m_AdditionalVertexStreams: {fileID: 0}
|
||||
--- !u!33 &910242488
|
||||
MeshFilter:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 910242485}
|
||||
m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0}
|
||||
--- !u!64 &910242489
|
||||
MeshCollider:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 910242485}
|
||||
m_Material: {fileID: 0}
|
||||
m_IncludeLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 0
|
||||
m_ExcludeLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 0
|
||||
m_LayerOverridePriority: 0
|
||||
m_IsTrigger: 0
|
||||
m_ProvidesContacts: 0
|
||||
m_Enabled: 1
|
||||
serializedVersion: 5
|
||||
m_Convex: 0
|
||||
m_CookingOptions: 30
|
||||
m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0}
|
||||
--- !u!1 &924212660
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 924212661}
|
||||
- component: {fileID: 924212662}
|
||||
- component: {fileID: 924212665}
|
||||
- component: {fileID: 924212663}
|
||||
- component: {fileID: 924212666}
|
||||
- component: {fileID: 924212667}
|
||||
- component: {fileID: 924212668}
|
||||
m_Layer: 0
|
||||
m_Name: Main Camera
|
||||
m_TagString: MainCamera
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &924212661
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 924212660}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0.7071068, y: 0, z: 0, w: 0.7071068}
|
||||
m_LocalPosition: {x: 0, y: 151.15788, z: 0.000018019422}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!20 &924212662
|
||||
Camera:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 924212660}
|
||||
m_Enabled: 1
|
||||
serializedVersion: 2
|
||||
m_ClearFlags: 1
|
||||
m_BackGroundColor: {r: 0, g: 0, b: 0, a: 0.019607844}
|
||||
m_projectionMatrixMode: 1
|
||||
m_GateFitMode: 2
|
||||
m_FOVAxisMode: 0
|
||||
m_Iso: 200
|
||||
m_ShutterSpeed: 0.005
|
||||
m_Aperture: 16
|
||||
m_FocusDistance: 10
|
||||
m_FocalLength: 50
|
||||
m_BladeCount: 5
|
||||
m_Curvature: {x: 2, y: 11}
|
||||
m_BarrelClipping: 0.25
|
||||
m_Anamorphism: 0
|
||||
m_SensorSize: {x: 36, y: 24}
|
||||
m_LensShift: {x: 0, y: 0}
|
||||
m_NormalizedViewPortRect:
|
||||
serializedVersion: 2
|
||||
x: 0
|
||||
y: 0
|
||||
width: 1
|
||||
height: 1
|
||||
near clip plane: 10
|
||||
far clip plane: 1400
|
||||
field of view: 60
|
||||
orthographic: 0
|
||||
orthographic size: 100
|
||||
m_Depth: -1
|
||||
m_CullingMask:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
m_RenderingPath: -1
|
||||
m_TargetTexture: {fileID: 0}
|
||||
m_TargetDisplay: 0
|
||||
m_TargetEye: 3
|
||||
m_HDR: 0
|
||||
m_AllowMSAA: 1
|
||||
m_AllowDynamicResolution: 0
|
||||
m_ForceIntoRT: 0
|
||||
m_OcclusionCulling: 1
|
||||
m_StereoConvergence: 10
|
||||
m_StereoSeparation: 0.022
|
||||
--- !u!81 &924212663
|
||||
AudioListener:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 924212660}
|
||||
m_Enabled: 1
|
||||
--- !u!124 &924212665
|
||||
Behaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 924212660}
|
||||
m_Enabled: 1
|
||||
--- !u!114 &924212666
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 924212660}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: db9dd0f9051524c2c87924ce0b79f2a6, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
selectionBox:
|
||||
m_Name:
|
||||
m_Normal:
|
||||
m_Background: {fileID: 0}
|
||||
m_ScaledBackgrounds: []
|
||||
m_TextColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
m_Hover:
|
||||
m_Background: {fileID: 0}
|
||||
m_ScaledBackgrounds: []
|
||||
m_TextColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
m_Active:
|
||||
m_Background: {fileID: 0}
|
||||
m_ScaledBackgrounds: []
|
||||
m_TextColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
m_Focused:
|
||||
m_Background: {fileID: 0}
|
||||
m_ScaledBackgrounds: []
|
||||
m_TextColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
m_OnNormal:
|
||||
m_Background: {fileID: 0}
|
||||
m_ScaledBackgrounds: []
|
||||
m_TextColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
m_OnHover:
|
||||
m_Background: {fileID: 0}
|
||||
m_ScaledBackgrounds: []
|
||||
m_TextColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
m_OnActive:
|
||||
m_Background: {fileID: 0}
|
||||
m_ScaledBackgrounds: []
|
||||
m_TextColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
m_OnFocused:
|
||||
m_Background: {fileID: 0}
|
||||
m_ScaledBackgrounds: []
|
||||
m_TextColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
m_Border:
|
||||
m_Left: 0
|
||||
m_Right: 0
|
||||
m_Top: 0
|
||||
m_Bottom: 0
|
||||
m_Margin:
|
||||
m_Left: 0
|
||||
m_Right: 0
|
||||
m_Top: 0
|
||||
m_Bottom: 0
|
||||
m_Padding:
|
||||
m_Left: 0
|
||||
m_Right: 0
|
||||
m_Top: 0
|
||||
m_Bottom: 0
|
||||
m_Overflow:
|
||||
m_Left: 0
|
||||
m_Right: 0
|
||||
m_Top: 0
|
||||
m_Bottom: 0
|
||||
m_Font: {fileID: 0}
|
||||
m_FontSize: 0
|
||||
m_FontStyle: 0
|
||||
m_Alignment: 0
|
||||
m_WordWrap: 0
|
||||
m_RichText: 1
|
||||
m_TextClipping: 1
|
||||
m_ImagePosition: 0
|
||||
m_ContentOffset: {x: 0, y: 0}
|
||||
m_FixedWidth: 0
|
||||
m_FixedHeight: 0
|
||||
m_StretchWidth: 1
|
||||
m_StretchHeight: 0
|
||||
adjustCamera: 1
|
||||
--- !u!114 &924212667
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 924212660}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 786ae4169b6714241b0ba3c766cdc57f, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!114 &924212668
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 924212660}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 3a705f1fd95105f4582d18bf472edc13, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
page: example_local_avoidance_lightweight
|
||||
--- !u!1 &1192988231
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 1192988233}
|
||||
- component: {fileID: 1192988232}
|
||||
m_Layer: 0
|
||||
m_Name: Canvas
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!223 &1192988232
|
||||
Canvas:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1192988231}
|
||||
m_Enabled: 1
|
||||
serializedVersion: 3
|
||||
m_RenderMode: 0
|
||||
m_Camera: {fileID: 0}
|
||||
m_PlaneDistance: 100
|
||||
m_PixelPerfect: 1
|
||||
m_ReceivesEvents: 1
|
||||
m_OverrideSorting: 0
|
||||
m_OverridePixelPerfect: 0
|
||||
m_SortingBucketNormalizedSize: 0
|
||||
m_VertexColorAlwaysGammaSpace: 0
|
||||
m_AdditionalShaderChannelsFlag: 25
|
||||
m_UpdateRectTransformForStandalone: 0
|
||||
m_SortingLayerID: 0
|
||||
m_SortingOrder: 0
|
||||
m_TargetDisplay: 0
|
||||
--- !u!224 &1192988233
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1192988231}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 0, y: 0, z: 0}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children:
|
||||
- {fileID: 581733580}
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 0, y: 0}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 0, y: 0}
|
||||
m_Pivot: {x: 0, y: 0}
|
||||
--- !u!1 &1813726531
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 1813726532}
|
||||
- component: {fileID: 1813726533}
|
||||
m_Layer: 0
|
||||
m_Name: Directional light
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &1813726532
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1813726531}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0.3535534, y: 0.3535534, z: -0.14644665, w: 0.85355335}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!108 &1813726533
|
||||
Light:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1813726531}
|
||||
m_Enabled: 1
|
||||
serializedVersion: 11
|
||||
m_Type: 1
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_Intensity: 1.4
|
||||
m_Range: 10
|
||||
m_SpotAngle: 30
|
||||
m_InnerSpotAngle: 21.80208
|
||||
m_CookieSize: 10
|
||||
m_Shadows:
|
||||
m_Type: 2
|
||||
m_Resolution: -1
|
||||
m_CustomResolution: -1
|
||||
m_Strength: 1
|
||||
m_Bias: 0.05
|
||||
m_NormalBias: 0.4
|
||||
m_NearPlane: 0.2
|
||||
m_CullingMatrixOverride:
|
||||
e00: 1
|
||||
e01: 0
|
||||
e02: 0
|
||||
e03: 0
|
||||
e10: 0
|
||||
e11: 1
|
||||
e12: 0
|
||||
e13: 0
|
||||
e20: 0
|
||||
e21: 0
|
||||
e22: 1
|
||||
e23: 0
|
||||
e30: 0
|
||||
e31: 0
|
||||
e32: 0
|
||||
e33: 1
|
||||
m_UseCullingMatrixOverride: 0
|
||||
m_Cookie: {fileID: 0}
|
||||
m_DrawHalo: 0
|
||||
m_Flare: {fileID: 0}
|
||||
m_RenderMode: 0
|
||||
m_CullingMask:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
m_RenderingLayerMask: 1
|
||||
m_Lightmapping: 1
|
||||
m_LightShadowCasterMode: 0
|
||||
m_AreaSize: {x: 1, y: 1}
|
||||
m_BounceIntensity: 2
|
||||
m_ColorTemperature: 6570
|
||||
m_UseColorTemperature: 0
|
||||
m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_UseBoundingSphereOverride: 0
|
||||
m_UseViewFrustumForShadowCasterCull: 1
|
||||
m_ShadowRadius: 0
|
||||
m_ShadowAngle: 10
|
||||
--- !u!1660057539 &9223372036854775807
|
||||
SceneRoots:
|
||||
m_ObjectHideFlags: 0
|
||||
m_Roots:
|
||||
- {fileID: 1813726532}
|
||||
- {fileID: 924212661}
|
||||
- {fileID: 687969039}
|
||||
- {fileID: 910242486}
|
||||
- {fileID: 157608483}
|
||||
- {fileID: 1192988233}
|
@@ -0,0 +1,14 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6bfac68e208594c79a32892bbc28dc1e
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 87744
|
||||
packageName: A* Pathfinding Project Pro
|
||||
packageVersion: 5.3.8
|
||||
assetPath: Packages/com.arongranberg.astar/ExampleScenes~/Scenes/LocalAvoidance/LocalAvoidanceLightweight.unity
|
||||
uploadId: 764484
|
@@ -0,0 +1,63 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!850595691 &4890085278179872738
|
||||
LightingSettings:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: LocalAvoidanceLightweightSettings
|
||||
serializedVersion: 2
|
||||
m_GIWorkflowMode: 1
|
||||
m_EnableBakedLightmaps: 1
|
||||
m_EnableRealtimeLightmaps: 0
|
||||
m_RealtimeEnvironmentLighting: 1
|
||||
m_BounceScale: 1
|
||||
m_AlbedoBoost: 1
|
||||
m_IndirectOutputScale: 1
|
||||
m_UsingShadowmask: 0
|
||||
m_BakeBackend: 0
|
||||
m_LightmapMaxSize: 1024
|
||||
m_BakeResolution: 50
|
||||
m_Padding: 2
|
||||
m_TextureCompression: 0
|
||||
m_AO: 0
|
||||
m_AOMaxDistance: 1
|
||||
m_CompAOExponent: 0
|
||||
m_CompAOExponentDirect: 0
|
||||
m_ExtractAO: 0
|
||||
m_MixedBakeMode: 1
|
||||
m_LightmapsBakeMode: 1
|
||||
m_FilterMode: 1
|
||||
m_LightmapParameters: {fileID: 0}
|
||||
m_ExportTrainingData: 0
|
||||
m_TrainingDataDestination: TrainingData
|
||||
m_RealtimeResolution: 1
|
||||
m_ForceWhiteAlbedo: 0
|
||||
m_ForceUpdates: 0
|
||||
m_FinalGather: 0
|
||||
m_FinalGatherRayCount: 1024
|
||||
m_FinalGatherFiltering: 1
|
||||
m_PVRCulling: 1
|
||||
m_PVRSampling: 1
|
||||
m_PVRDirectSampleCount: 32
|
||||
m_PVRSampleCount: 500
|
||||
m_PVREnvironmentSampleCount: 500
|
||||
m_PVREnvironmentReferencePointCount: 2048
|
||||
m_LightProbeSampleCountMultiplier: 4
|
||||
m_PVRBounces: 2
|
||||
m_PVRRussianRouletteStartBounce: 2
|
||||
m_PVREnvironmentMIS: 0
|
||||
m_PVRFilteringMode: 0
|
||||
m_PVRDenoiserTypeDirect: 0
|
||||
m_PVRDenoiserTypeIndirect: 0
|
||||
m_PVRDenoiserTypeAO: 0
|
||||
m_PVRFilterTypeDirect: 0
|
||||
m_PVRFilterTypeIndirect: 0
|
||||
m_PVRFilterTypeAO: 0
|
||||
m_PVRFilteringGaussRadiusDirect: 1
|
||||
m_PVRFilteringGaussRadiusIndirect: 5
|
||||
m_PVRFilteringGaussRadiusAO: 2
|
||||
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
|
||||
m_PVRFilteringAtrousPositionSigmaIndirect: 2
|
||||
m_PVRFilteringAtrousPositionSigmaAO: 1
|
@@ -0,0 +1,15 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4dbab546d071f2be28c7f23a07f95a6b
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 87744
|
||||
packageName: A* Pathfinding Project Pro
|
||||
packageVersion: 5.3.8
|
||||
assetPath: Packages/com.arongranberg.astar/ExampleScenes~/Scenes/LocalAvoidance/LocalAvoidanceLightweightSettings.lighting
|
||||
uploadId: 764484
|
@@ -0,0 +1,63 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!850595691 &4890085278179872738
|
||||
LightingSettings:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: LocalAvoidanceSettings
|
||||
serializedVersion: 2
|
||||
m_GIWorkflowMode: 1
|
||||
m_EnableBakedLightmaps: 1
|
||||
m_EnableRealtimeLightmaps: 0
|
||||
m_RealtimeEnvironmentLighting: 1
|
||||
m_BounceScale: 1
|
||||
m_AlbedoBoost: 1
|
||||
m_IndirectOutputScale: 1
|
||||
m_UsingShadowmask: 0
|
||||
m_BakeBackend: 0
|
||||
m_LightmapMaxSize: 1024
|
||||
m_BakeResolution: 1
|
||||
m_Padding: 2
|
||||
m_TextureCompression: 0
|
||||
m_AO: 0
|
||||
m_AOMaxDistance: 1
|
||||
m_CompAOExponent: 0
|
||||
m_CompAOExponentDirect: 0
|
||||
m_ExtractAO: 0
|
||||
m_MixedBakeMode: 1
|
||||
m_LightmapsBakeMode: 1
|
||||
m_FilterMode: 1
|
||||
m_LightmapParameters: {fileID: 0}
|
||||
m_ExportTrainingData: 0
|
||||
m_TrainingDataDestination: TrainingData
|
||||
m_RealtimeResolution: 1
|
||||
m_ForceWhiteAlbedo: 0
|
||||
m_ForceUpdates: 0
|
||||
m_FinalGather: 0
|
||||
m_FinalGatherRayCount: 1024
|
||||
m_FinalGatherFiltering: 1
|
||||
m_PVRCulling: 1
|
||||
m_PVRSampling: 1
|
||||
m_PVRDirectSampleCount: 32
|
||||
m_PVRSampleCount: 500
|
||||
m_PVREnvironmentSampleCount: 500
|
||||
m_PVREnvironmentReferencePointCount: 2048
|
||||
m_LightProbeSampleCountMultiplier: 4
|
||||
m_PVRBounces: 2
|
||||
m_PVRRussianRouletteStartBounce: 2
|
||||
m_PVREnvironmentMIS: 0
|
||||
m_PVRFilteringMode: 0
|
||||
m_PVRDenoiserTypeDirect: 0
|
||||
m_PVRDenoiserTypeIndirect: 0
|
||||
m_PVRDenoiserTypeAO: 0
|
||||
m_PVRFilterTypeDirect: 0
|
||||
m_PVRFilterTypeIndirect: 0
|
||||
m_PVRFilterTypeAO: 0
|
||||
m_PVRFilteringGaussRadiusDirect: 1
|
||||
m_PVRFilteringGaussRadiusIndirect: 5
|
||||
m_PVRFilteringGaussRadiusAO: 2
|
||||
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
|
||||
m_PVRFilteringAtrousPositionSigmaIndirect: 2
|
||||
m_PVRFilteringAtrousPositionSigmaAO: 1
|
@@ -0,0 +1,15 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cd772680b74b7360c89d3a70ce0c61e1
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 87744
|
||||
packageName: A* Pathfinding Project Pro
|
||||
packageVersion: 5.3.8
|
||||
assetPath: Packages/com.arongranberg.astar/ExampleScenes~/Scenes/LocalAvoidance/LocalAvoidanceSettings.lighting
|
||||
uploadId: 764484
|
@@ -0,0 +1,229 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!1 &100000
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 400000}
|
||||
- component: {fileID: 3300000}
|
||||
- component: {fileID: 2300000}
|
||||
m_Layer: 1
|
||||
m_Name: Plane
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &400000
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 100000}
|
||||
m_LocalRotation: {x: 0.7071068, y: 0, z: 0, w: 0.7071067}
|
||||
m_LocalPosition: {x: 0, y: 0.5, z: 0}
|
||||
m_LocalScale: {x: 4, y: 4, z: 4}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 400002}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!33 &3300000
|
||||
MeshFilter:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 100000}
|
||||
m_Mesh: {fileID: 10210, guid: 0000000000000000e000000000000000, type: 0}
|
||||
--- !u!23 &2300000
|
||||
MeshRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 100000}
|
||||
m_Enabled: 1
|
||||
m_CastShadows: 1
|
||||
m_ReceiveShadows: 1
|
||||
m_DynamicOccludee: 1
|
||||
m_MotionVectors: 1
|
||||
m_LightProbeUsage: 0
|
||||
m_ReflectionProbeUsage: 1
|
||||
m_RayTracingMode: 2
|
||||
m_RenderingLayerMask: 1
|
||||
m_RendererPriority: 0
|
||||
m_Materials:
|
||||
- {fileID: 2100000, guid: 56c8a729c9a28cc509373ce53c67138b, type: 2}
|
||||
m_StaticBatchInfo:
|
||||
firstSubMesh: 0
|
||||
subMeshCount: 0
|
||||
m_StaticBatchRoot: {fileID: 0}
|
||||
m_ProbeAnchor: {fileID: 0}
|
||||
m_LightProbeVolumeOverride: {fileID: 0}
|
||||
m_ScaleInLightmap: 1
|
||||
m_ReceiveGI: 1
|
||||
m_PreserveUVs: 0
|
||||
m_IgnoreNormalsForChartDetection: 0
|
||||
m_ImportantGI: 0
|
||||
m_StitchLightmapSeams: 1
|
||||
m_SelectedEditorRenderState: 3
|
||||
m_MinimumChartSize: 4
|
||||
m_AutoUVMaxDistance: 0.5
|
||||
m_AutoUVMaxAngle: 89
|
||||
m_LightmapParameters: {fileID: 0}
|
||||
m_SortingLayerID: 0
|
||||
m_SortingLayer: 0
|
||||
m_SortingOrder: 0
|
||||
--- !u!1 &100002
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 400002}
|
||||
- component: {fileID: 11400004}
|
||||
- component: {fileID: 11400002}
|
||||
- component: {fileID: 11400000}
|
||||
- component: {fileID: 11400006}
|
||||
- component: {fileID: 11435192}
|
||||
m_Layer: 1
|
||||
m_Name: RVOAgent
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &400002
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 100002}
|
||||
m_LocalRotation: {x: 0, y: 0.74402404, z: 0, w: 0.66815287}
|
||||
m_LocalPosition: {x: -137.57237, y: 5.377716, z: 191.38498}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children:
|
||||
- {fileID: 400000}
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &11400004
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 100002}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 67057d14b4f9f4919958ec635b71f22b, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
repathRate: 1
|
||||
maxSpeed: 10
|
||||
moveNextDist: 5
|
||||
slowdownDistance: 5
|
||||
groundMask:
|
||||
serializedVersion: 2
|
||||
m_Bits: 1
|
||||
--- !u!114 &11400002
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 100002}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 373b52eb9bf8c40f785bb6947a1aee66, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
version: 1
|
||||
drawGizmos: 0
|
||||
detailedGizmos: 0
|
||||
startEndModifier:
|
||||
addPoints: 0
|
||||
exactStartPoint: 1
|
||||
exactEndPoint: 3
|
||||
useRaycasting: 0
|
||||
mask:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
useGraphRaycasting: 0
|
||||
traversableTags: -1
|
||||
tagPenalties: 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
graphMask:
|
||||
value: -1
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 100002}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 77f586f285b3847808d79083bd19ef1f, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
version: 1
|
||||
quality: 0
|
||||
unwrap: 1
|
||||
splitAtEveryPortal: 0
|
||||
--- !u!114 &11400006
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 100002}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: cb6a34d769a1e4ac7b0b30e433aa443c, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
version: 1
|
||||
smoothType: 2
|
||||
subdivisions: 2
|
||||
iterations: 2
|
||||
strength: 0.5
|
||||
uniformLength: 1
|
||||
maxSegmentLength: 2
|
||||
bezierTangentLength: 0.4
|
||||
offset: 2
|
||||
factor: 0.1
|
||||
--- !u!114 &11435192
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 100002}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 560112f876f5746c780eca0d404e7139, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
version: 2
|
||||
radiusBackingField: 2
|
||||
heightBackingField: 4
|
||||
centerBackingField: 2
|
||||
locked: 0
|
||||
lockWhenNotMoving: 0
|
||||
agentTimeHorizon: 2
|
||||
obstacleTimeHorizon: 2
|
||||
maxNeighbours: 10
|
||||
layer: 1
|
||||
collidesWith: -5
|
||||
wallAvoidForce: 1
|
||||
wallAvoidFalloff: 1
|
||||
priority: 0.5
|
||||
debug: 0
|
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dbf1877db1c4f4ff3930d903c0f5bb28
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 87744
|
||||
packageName: A* Pathfinding Project Pro
|
||||
packageVersion: 5.3.8
|
||||
assetPath: Packages/com.arongranberg.astar/ExampleScenes~/Scenes/LocalAvoidance/RVOAgent.prefab
|
||||
uploadId: 764484
|
@@ -0,0 +1,57 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
namespace Pathfinding.Examples {
|
||||
/// <summary>
|
||||
/// Places ROV agents in circles.
|
||||
/// Used in a example scene
|
||||
/// </summary>
|
||||
[HelpURL("https://arongranberg.com/astar/documentation/stable/rvoagentplacer.html")]
|
||||
public class RVOAgentPlacer : MonoBehaviour {
|
||||
public int agents = 100;
|
||||
|
||||
public float ringSize = 100;
|
||||
public LayerMask mask;
|
||||
|
||||
public GameObject prefab;
|
||||
|
||||
public Vector3 goalOffset;
|
||||
|
||||
public float repathRate = 1;
|
||||
|
||||
// Use this for initialization
|
||||
IEnumerator Start () {
|
||||
yield return null;
|
||||
|
||||
for (int i = 0; i < agents; i++) {
|
||||
float angle = ((float)i / agents)*(float)System.Math.PI*2;
|
||||
|
||||
Vector3 pos = new Vector3((float)System.Math.Cos(angle), 0, (float)System.Math.Sin(angle))*ringSize;
|
||||
Vector3 antipodal = -pos + goalOffset;
|
||||
|
||||
GameObject go = GameObject.Instantiate(prefab, Vector3.zero, Quaternion.Euler(0, angle+180, 0)) as GameObject;
|
||||
RVOExampleAgent ag = go.GetComponent<RVOExampleAgent>();
|
||||
|
||||
if (ag == null) {
|
||||
Debug.LogError("Prefab does not have an RVOExampleAgent component attached");
|
||||
yield break;
|
||||
}
|
||||
|
||||
//ag.radius = radius;
|
||||
go.transform.parent = transform;
|
||||
go.transform.position = pos;
|
||||
|
||||
ag.repathRate = repathRate;
|
||||
ag.SetTarget(antipodal);
|
||||
|
||||
ag.SetColor(GetColor(angle));
|
||||
}
|
||||
}
|
||||
|
||||
const float rad2Deg = 360.0f/ ((float)System.Math.PI*2);
|
||||
|
||||
public Color GetColor (float angle) {
|
||||
return AstarMath.HSVToRGB(angle * rad2Deg, 0.8f, 0.6f);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,14 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c42c8ec55e7cf4e76b727f9cde90212d
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 87744
|
||||
packageName: A* Pathfinding Project Pro
|
||||
packageVersion: 5.3.8
|
||||
assetPath: Packages/com.arongranberg.astar/ExampleScenes~/Scenes/LocalAvoidance/RVOAgentPlacer.cs
|
||||
uploadId: 764484
|
@@ -0,0 +1,186 @@
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
using Pathfinding.RVO;
|
||||
|
||||
namespace Pathfinding.Examples {
|
||||
/// <summary>
|
||||
/// Example movement script for using RVO.
|
||||
///
|
||||
/// Primarily intended for the example scenes.
|
||||
/// You can use the AIPath or RichAI movement scripts in your own projects.
|
||||
///
|
||||
/// See: <see cref="Pathfinding.AIPath"/>
|
||||
/// See: <see cref="Pathfinding.RichAI"/>
|
||||
/// See: <see cref="Pathfinding.RVO.RVOController"/>
|
||||
/// </summary>
|
||||
[RequireComponent(typeof(RVOController))]
|
||||
[RequireComponent(typeof(Seeker))]
|
||||
[HelpURL("https://arongranberg.com/astar/documentation/stable/rvoexampleagent.html")]
|
||||
public class RVOExampleAgent : MonoBehaviour {
|
||||
public float repathRate = 1;
|
||||
|
||||
private float nextRepath = 0;
|
||||
|
||||
private Vector3 target;
|
||||
private bool canSearchAgain = true;
|
||||
|
||||
private RVOController controller;
|
||||
public float maxSpeed = 10;
|
||||
|
||||
Path path = null;
|
||||
|
||||
List<Vector3> vectorPath;
|
||||
int wp;
|
||||
|
||||
public float moveNextDist = 1;
|
||||
public float slowdownDistance = 1;
|
||||
public LayerMask groundMask;
|
||||
|
||||
Seeker seeker;
|
||||
|
||||
MeshRenderer[] rends;
|
||||
|
||||
public void Awake () {
|
||||
seeker = GetComponent<Seeker>();
|
||||
controller = GetComponent<RVOController>();
|
||||
}
|
||||
|
||||
/// <summary>Set the point to move to</summary>
|
||||
public void SetTarget (Vector3 target) {
|
||||
this.target = target;
|
||||
RecalculatePath();
|
||||
}
|
||||
|
||||
/// <summary>Animate the change of color</summary>
|
||||
public void SetColor (Color color) {
|
||||
if (rends == null) rends = GetComponentsInChildren<MeshRenderer>();
|
||||
foreach (var rend in rends) {
|
||||
StartCoroutine(AnimateColor(rend, rend.material.GetColor("_Color"), color));
|
||||
}
|
||||
}
|
||||
|
||||
System.Collections.IEnumerator AnimateColor (MeshRenderer rend, Color startColor, Color endColor) {
|
||||
float t = 0;
|
||||
|
||||
do {
|
||||
t = Mathf.Min(1.0f, t + Time.deltaTime);
|
||||
rend.material.SetColor("_Color", Color.Lerp(startColor, endColor, t));
|
||||
yield return null;
|
||||
} while (t < 1);
|
||||
}
|
||||
|
||||
public void RecalculatePath () {
|
||||
canSearchAgain = false;
|
||||
nextRepath = Time.time+repathRate*(Random.value+0.5f);
|
||||
seeker.StartPath(transform.position, target, OnPathComplete);
|
||||
}
|
||||
|
||||
public void OnPathComplete (Path _p) {
|
||||
ABPath p = _p as ABPath;
|
||||
|
||||
canSearchAgain = true;
|
||||
|
||||
if (path != null) path.Release(this);
|
||||
path = p;
|
||||
p.Claim(this);
|
||||
|
||||
if (p.error) {
|
||||
wp = 0;
|
||||
vectorPath = null;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Vector3 p1 = p.originalStartPoint;
|
||||
Vector3 p2 = transform.position;
|
||||
p1.y = p2.y;
|
||||
float d = (p2-p1).magnitude;
|
||||
wp = 0;
|
||||
|
||||
vectorPath = p.vectorPath;
|
||||
Vector3 waypoint;
|
||||
|
||||
if (moveNextDist > 0) {
|
||||
for (float t = 0; t <= d; t += moveNextDist*0.6f) {
|
||||
wp--;
|
||||
Vector3 pos = p1 + (p2-p1)*t;
|
||||
|
||||
do {
|
||||
wp++;
|
||||
waypoint = vectorPath[wp];
|
||||
} while (controller.To2D(pos - waypoint).sqrMagnitude < moveNextDist*moveNextDist && wp != vectorPath.Count-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Update () {
|
||||
if (Time.time >= nextRepath && canSearchAgain) {
|
||||
RecalculatePath();
|
||||
}
|
||||
|
||||
Vector3 pos = transform.position;
|
||||
|
||||
if (vectorPath != null && vectorPath.Count > 1) {
|
||||
while ((controller.To2D(pos - vectorPath[wp]).sqrMagnitude < moveNextDist*moveNextDist && wp != vectorPath.Count-1) || wp == 0) {
|
||||
wp++;
|
||||
}
|
||||
|
||||
// Current path segment goes from vectorPath[wp-1] to vectorPath[wp]
|
||||
// We want to find the point on that segment that is 'moveNextDist' from our current position.
|
||||
// This can be visualized as finding the intersection of a circle with radius 'moveNextDist'
|
||||
// centered at our current position with that segment.
|
||||
var p1 = vectorPath[wp-1];
|
||||
var p2 = vectorPath[wp];
|
||||
|
||||
// Calculate the intersection with the circle. This involves some math.
|
||||
var t = VectorMath.LineCircleIntersectionFactor(controller.To2D(transform.position), controller.To2D(p1), controller.To2D(p2), moveNextDist);
|
||||
// Clamp to a point on the segment
|
||||
t = Mathf.Clamp01(t);
|
||||
Vector3 waypoint = Vector3.Lerp(p1, p2, t);
|
||||
|
||||
// Calculate distance to the end of the path
|
||||
float remainingDistance = controller.To2D(waypoint - pos).magnitude + controller.To2D(waypoint - p2).magnitude;
|
||||
for (int i = wp; i < vectorPath.Count - 1; i++) remainingDistance += controller.To2D(vectorPath[i+1] - vectorPath[i]).magnitude;
|
||||
|
||||
// Set the target to a point in the direction of the current waypoint at a distance
|
||||
// equal to the remaining distance along the path. Since the rvo agent assumes that
|
||||
// it should stop when it reaches the target point, this will produce good avoidance
|
||||
// behavior near the end of the path. When not close to the end point it will act just
|
||||
// as being commanded to move in a particular direction, not toward a particular point
|
||||
var rvoTarget = (waypoint - pos).normalized * remainingDistance + pos;
|
||||
// When within [slowdownDistance] units from the target, use a progressively lower speed
|
||||
var desiredSpeed = Mathf.Clamp01(remainingDistance / slowdownDistance) * maxSpeed;
|
||||
Debug.DrawLine(transform.position, waypoint, Color.red);
|
||||
controller.SetTarget(rvoTarget, desiredSpeed, maxSpeed, vectorPath[vectorPath.Count-1]);
|
||||
} else {
|
||||
// Stand still
|
||||
controller.SetTarget(pos, maxSpeed, maxSpeed, pos);
|
||||
}
|
||||
|
||||
// Get a processed movement delta from the rvo controller and move the character.
|
||||
// This is based on information from earlier frames.
|
||||
var movementDelta = controller.CalculateMovementDelta(Time.deltaTime);
|
||||
pos += movementDelta;
|
||||
|
||||
// Rotate the character if the velocity is not extremely small
|
||||
if (Time.deltaTime > 0 && movementDelta.magnitude / Time.deltaTime > 0.01f) {
|
||||
var rot = transform.rotation;
|
||||
var targetRot = Quaternion.LookRotation(movementDelta, controller.To3D(Vector2.zero, 1));
|
||||
const float RotationSpeed = 5;
|
||||
if (controller.movementPlaneMode == MovementPlane.XY) {
|
||||
targetRot = targetRot * Quaternion.Euler(-90, 180, 0);
|
||||
}
|
||||
transform.rotation = Quaternion.Slerp(rot, targetRot, Time.deltaTime * RotationSpeed);
|
||||
}
|
||||
|
||||
if (controller.movementPlaneMode == MovementPlane.XZ) {
|
||||
RaycastHit hit;
|
||||
if (Physics.Raycast(pos + Vector3.up, Vector3.down, out hit, 2, groundMask)) {
|
||||
pos.y = hit.point.y;
|
||||
}
|
||||
}
|
||||
|
||||
transform.position = pos;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,14 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 67057d14b4f9f4919958ec635b71f22b
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 87744
|
||||
packageName: A* Pathfinding Project Pro
|
||||
packageVersion: 5.3.8
|
||||
assetPath: Packages/com.arongranberg.astar/ExampleScenes~/Scenes/LocalAvoidance/RVOExampleAgent.cs
|
||||
uploadId: 764484
|
Binary file not shown.
@@ -0,0 +1,40 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 92aac0fea0f5e43e1a179927f0f9d953
|
||||
TextureImporter:
|
||||
serializedVersion: 2
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 1
|
||||
linearTexture: 0
|
||||
correctGamma: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: .25
|
||||
normalMapFilter: 0
|
||||
isReadable: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 0
|
||||
textureFormat: -1
|
||||
maxTextureSize: 1024
|
||||
textureSettings:
|
||||
filterMode: -1
|
||||
aniso: -1
|
||||
mipBias: -1
|
||||
wrapMode: -1
|
||||
nPOTScale: 1
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
textureType: -1
|
||||
buildTargetSettings: []
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 87744
|
||||
packageName: A* Pathfinding Project Pro
|
||||
packageVersion: 5.3.8
|
||||
assetPath: Packages/com.arongranberg.astar/ExampleScenes~/Scenes/LocalAvoidance/selectionBox.psd
|
||||
uploadId: 764484
|
Reference in New Issue
Block a user