Merge remote-tracking branch 'origin/main'
This commit is contained in:
commit
53d042bfb8
264
.gitlab-ci.yml
Normal file
264
.gitlab-ci.yml
Normal file
@ -0,0 +1,264 @@
|
||||
stages:
|
||||
- prepare
|
||||
- build_and_test
|
||||
- deploy
|
||||
|
||||
# If you are looking for a place where to add 'UNITY_LICENSE_FILE' and other secrets, please visit your project's gitlab page:
|
||||
# settings > CI/CD > Variables instead
|
||||
variables:
|
||||
BUILD_NAME: CaperMoive
|
||||
UNITY_ACTIVATION_FILE: ./unity3d.alf
|
||||
IMAGE: unityci/editor # https://hub.docker.com/r/unityci/editor
|
||||
IMAGE_VERSION: 1 # This will automatically use latest v1.x.x, see https://github.com/game-ci/docker/releases
|
||||
UNITY_DIR: $CI_PROJECT_DIR # this needs to be an absolute path. Defaults to the root of your tree.
|
||||
# You can expose this in Unity via Application.version
|
||||
VERSION_NUMBER_VAR: $CI_COMMIT_REF_SLUG-$CI_PIPELINE_ID-$CI_JOB_ID
|
||||
VERSION_BUILD_VAR: $CI_PIPELINE_IID
|
||||
|
||||
image: $IMAGE:$UNITY_VERSION-base-$IMAGE_VERSION
|
||||
|
||||
get-unity-version:
|
||||
image: alpine
|
||||
stage: prepare
|
||||
variables:
|
||||
GIT_DEPTH: 1
|
||||
script:
|
||||
- apk add --no-cache grep gawk coreutils
|
||||
- echo UNITY_VERSION=$(cat $UNITY_DIR/ProjectSettings/ProjectVersion.txt | grep "m_EditorVersion:.*" | awk '{ print $2}') | tee prepare.env
|
||||
artifacts:
|
||||
reports:
|
||||
dotenv: prepare.env
|
||||
|
||||
.unity_before_script: &unity_before_script
|
||||
before_script:
|
||||
- chmod +x ./ci/before_script.sh && ./ci/before_script.sh
|
||||
needs:
|
||||
- job: get-unity-version
|
||||
artifacts: true
|
||||
|
||||
.cache: &cache
|
||||
cache:
|
||||
key: "$CI_PROJECT_NAMESPACE-$CI_PROJECT_NAME-$CI_COMMIT_REF_SLUG-$TEST_PLATFORM"
|
||||
paths:
|
||||
- $UNITY_DIR/Library/
|
||||
|
||||
.license: &license
|
||||
rules:
|
||||
- if: '$UNITY_LICENSE != null'
|
||||
when: always
|
||||
|
||||
.unity_defaults: &unity_defaults
|
||||
<<:
|
||||
- *unity_before_script
|
||||
- *cache
|
||||
- *license
|
||||
|
||||
# run this job when you need to request a license
|
||||
# you may need to follow activation steps from documentation
|
||||
get-activation-file:
|
||||
<<: *unity_before_script
|
||||
rules:
|
||||
- if: '$UNITY_LICENSE == null'
|
||||
when: manual
|
||||
stage: prepare
|
||||
script:
|
||||
- chmod +x ./ci/get_activation_file.sh && ./ci/get_activation_file.sh
|
||||
artifacts:
|
||||
paths:
|
||||
- $UNITY_ACTIVATION_FILE
|
||||
expire_in: 10 min # Expiring this as artifacts may contain sensitive data and should not be kept public
|
||||
|
||||
.test: &test
|
||||
stage: build_and_test
|
||||
<<: *unity_defaults
|
||||
script:
|
||||
- chmod +x ./ci/test.sh && ./ci/test.sh
|
||||
artifacts:
|
||||
when: always
|
||||
expire_in: 2 weeks
|
||||
# https://gitlab.com/gableroux/unity3d-gitlab-ci-example/-/issues/83
|
||||
# you may need to remove or replace these to fit your need if you are using your own runners
|
||||
tags:
|
||||
- gitlab-org
|
||||
coverage: /<Linecoverage>(.*?)</Linecoverage>/
|
||||
|
||||
# Tests without junit reporting results in GitLab
|
||||
# test-playmode:
|
||||
# <<: *test
|
||||
# variables:
|
||||
# TEST_PLATFORM: playmode
|
||||
# TESTING_TYPE: NUNIT
|
||||
|
||||
# test-editmode:
|
||||
# <<: *test
|
||||
# variables:
|
||||
# TEST_PLATFORM: editmode
|
||||
# TESTING_TYPE: NUNIT
|
||||
|
||||
# uncomment the following blocks if you'd like to have junit reporting unity test results in gitlab
|
||||
# We currently have the following issue which prevents it from working right now, but you can give
|
||||
# a hand if you're interested in this feature:
|
||||
# https://gitlab.com/gableroux/unity3d-gitlab-ci-example/-/issues/151
|
||||
|
||||
.test-with-junit-reports: &test-with-junit-reports
|
||||
stage: build_and_test
|
||||
<<: *unity_defaults
|
||||
script:
|
||||
# This could be made faster by adding these packages to base image or running in a separate job (and step)
|
||||
# We could use an image with these two depencencies only and only do the saxonb-xslt command on
|
||||
# previous job's artifacts
|
||||
- apt-get update && apt-get install -y default-jre libsaxonb-java
|
||||
- chmod +x ./ci/test.sh && ./ci/test.sh
|
||||
- saxonb-xslt -s $UNITY_DIR/$TEST_PLATFORM-results.xml -xsl $CI_PROJECT_DIR/ci/nunit-transforms/nunit3-junit.xslt >$UNITY_DIR/$TEST_PLATFORM-junit-results.xml
|
||||
artifacts:
|
||||
when: always
|
||||
paths:
|
||||
# This is exported to allow viewing the Coverage Report in detail if needed
|
||||
- $UNITY_DIR/$TEST_PLATFORM-coverage/
|
||||
reports:
|
||||
junit:
|
||||
- $UNITY_DIR/$TEST_PLATFORM-junit-results.xml
|
||||
- "$UNITY_DIR/$TEST_PLATFORM-coverage/coverage.xml"
|
||||
expire_in: 2 weeks
|
||||
# https://gitlab.com/gableroux/unity3d-gitlab-ci-example/-/issues/83
|
||||
# you may need to remove or replace these to fit your need if you are using your own runners
|
||||
tags:
|
||||
- gitlab-org
|
||||
coverage: /<Linecoverage>(.*?)</Linecoverage>/
|
||||
|
||||
test-playmode-with-junit-reports:
|
||||
<<: *test-with-junit-reports
|
||||
variables:
|
||||
TEST_PLATFORM: playmode
|
||||
TESTING_TYPE: JUNIT
|
||||
|
||||
test-editmode-with-junit-reports:
|
||||
<<: *test-with-junit-reports
|
||||
variables:
|
||||
TEST_PLATFORM: editmode
|
||||
TESTING_TYPE: JUNIT
|
||||
|
||||
.build: &build
|
||||
stage: build_and_test
|
||||
<<: *unity_defaults
|
||||
script:
|
||||
- chmod +x ./ci/build.sh && ./ci/build.sh
|
||||
artifacts:
|
||||
paths:
|
||||
- $UNITY_DIR/Builds/
|
||||
# https://gitlab.com/gableroux/unity3d-gitlab-ci-example/-/issues/83
|
||||
# you may need to remove or replace these to fit your need if you are using your own runners
|
||||
tags:
|
||||
- gitlab-org
|
||||
|
||||
# build-StandaloneLinux64:
|
||||
# <<: *build
|
||||
# variables:
|
||||
# BUILD_TARGET: StandaloneLinux64
|
||||
|
||||
# build-StandaloneLinux64-il2cpp:
|
||||
# <<: *build
|
||||
# image: $IMAGE:$UNITY_VERSION-linux-il2cpp-$IMAGE_VERSION
|
||||
# variables:
|
||||
# BUILD_TARGET: StandaloneLinux64
|
||||
# SCRIPTING_BACKEND: IL2CPP
|
||||
|
||||
build-StandaloneOSX:
|
||||
<<: *build
|
||||
image: $IMAGE:$UNITY_VERSION-mac-mono-$IMAGE_VERSION
|
||||
variables:
|
||||
BUILD_TARGET: StandaloneOSX
|
||||
|
||||
#Note: build target names changed in recent versions, use this for versions < 2017.2:
|
||||
# build-StandaloneOSXUniversal:
|
||||
# <<: *build
|
||||
# variables:
|
||||
# BUILD_TARGET: StandaloneOSXUniversal
|
||||
|
||||
build-StandaloneWindows64:
|
||||
<<: *build
|
||||
image: $IMAGE:$UNITY_VERSION-windows-mono-$IMAGE_VERSION
|
||||
variables:
|
||||
BUILD_TARGET: StandaloneWindows64
|
||||
|
||||
# For webgl support, you need to set Compression Format to Disabled for v0.9. See https://github.com/game-ci/docker/issues/75
|
||||
build-WebGL:
|
||||
<<: *build
|
||||
image: $IMAGE:$UNITY_VERSION-webgl-$IMAGE_VERSION
|
||||
# Temporary workaround for https://github.com/game-ci/docker/releases/tag/v0.9 and webgl support in current project to prevent errors with missing ffmpeg
|
||||
before_script:
|
||||
- chmod +x ./ci/before_script.sh && ./ci/before_script.sh
|
||||
- apt-get update && apt-get install ffmpeg -y
|
||||
variables:
|
||||
BUILD_TARGET: WebGL
|
||||
|
||||
# build-android:
|
||||
# <<: *build
|
||||
# image: $IMAGE:$UNITY_VERSION-android-$IMAGE_VERSION
|
||||
# variables:
|
||||
# BUILD_TARGET: Android
|
||||
# BUILD_APP_BUNDLE: "false"
|
||||
|
||||
# build-android-il2cpp:
|
||||
# <<: *build
|
||||
# image: $IMAGE:$UNITY_VERSION-android-$IMAGE_VERSION
|
||||
# variables:
|
||||
# BUILD_TARGET: Android
|
||||
# BUILD_APP_BUNDLE: "false"
|
||||
# SCRIPTING_BACKEND: IL2CPP
|
||||
|
||||
#deploy-android:
|
||||
# stage: deploy
|
||||
# image: ruby
|
||||
# script:
|
||||
# - cd $UNITY_DIR/Builds/Android
|
||||
# - echo $GPC_TOKEN > gpc_token.json
|
||||
# - gem install bundler
|
||||
# - bundle install
|
||||
# - fastlane supply --aab "${BUILD_NAME}.aab" --track internal --package_name com.youcompany.yourgame --json_key ./gpc_token.json
|
||||
# needs: ["build-android"]
|
||||
|
||||
# build-ios-xcode:
|
||||
# <<: *build
|
||||
# image: $IMAGE:$UNITY_VERSION-ios-$IMAGE_VERSION
|
||||
# variables:
|
||||
# BUILD_TARGET: iOS
|
||||
|
||||
#build-and-deploy-ios:
|
||||
# stage: deploy
|
||||
# script:
|
||||
# - cd $UNITY_DIR/Builds/iOS/$BUILD_NAME
|
||||
# - pod install
|
||||
# - fastlane ios beta
|
||||
# tags:
|
||||
# - ios
|
||||
# - mac
|
||||
# needs: ["build-ios-xcode"]
|
||||
|
||||
pages:
|
||||
image: alpine:latest
|
||||
stage: deploy
|
||||
script:
|
||||
- mv "$UNITY_DIR/Builds/WebGL/${BUILD_NAME}" public
|
||||
artifacts:
|
||||
paths:
|
||||
- public
|
||||
only:
|
||||
- $CI_DEFAULT_BRANCH
|
||||
|
||||
|
||||
workflow:
|
||||
rules:
|
||||
- if: '$CI_COMMIT_MESSAGE =~ /RunJob/'
|
||||
when: always
|
||||
- when: never
|
||||
|
||||
|
||||
# workflow:
|
||||
# rules:
|
||||
# # - if: $CI_MERGE_REQUEST_ID
|
||||
# - if: $CI_COMMIT_BRANCH == "release"
|
||||
# when: always
|
||||
# # - if: $CI_COMMIT_TAG
|
||||
# # when: never
|
||||
# - when: never
|
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,6 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2d6d5d59d45ce8a4784ba6c47984a23e
|
||||
guid: 6137c7fcdd7b4684f8676bd3e1b3cf48
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
@ -1,5 +1,6 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a064949e8b7c31e4699684de4fb7ff30
|
||||
guid: 4c385efc10803524f8c37fe3c90183ed
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
1436
BlueWater/Assets/05.Prefabs/Infantryman.prefab
Normal file
1436
BlueWater/Assets/05.Prefabs/Infantryman.prefab
Normal file
File diff suppressed because it is too large
Load Diff
7
BlueWater/Assets/05.Prefabs/Infantryman.prefab.meta
Normal file
7
BlueWater/Assets/05.Prefabs/Infantryman.prefab.meta
Normal file
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5f3eb25081a4e3e4095e8b036bd89aaf
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
1435
BlueWater/Assets/05.Prefabs/Scout.prefab
Normal file
1435
BlueWater/Assets/05.Prefabs/Scout.prefab
Normal file
File diff suppressed because it is too large
Load Diff
7
BlueWater/Assets/05.Prefabs/Scout.prefab.meta
Normal file
7
BlueWater/Assets/05.Prefabs/Scout.prefab.meta
Normal file
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: db20c101f214d8c4e866c80cc5858c94
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
1436
BlueWater/Assets/05.Prefabs/SpearShieldman.prefab
Normal file
1436
BlueWater/Assets/05.Prefabs/SpearShieldman.prefab
Normal file
File diff suppressed because it is too large
Load Diff
7
BlueWater/Assets/05.Prefabs/SpearShieldman.prefab.meta
Normal file
7
BlueWater/Assets/05.Prefabs/SpearShieldman.prefab.meta
Normal file
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c0058ee844e20de49828093773aef61c
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
1351
BlueWater/Assets/05.Prefabs/Spearman.prefab
Normal file
1351
BlueWater/Assets/05.Prefabs/Spearman.prefab
Normal file
File diff suppressed because it is too large
Load Diff
7
BlueWater/Assets/05.Prefabs/Spearman.prefab.meta
Normal file
7
BlueWater/Assets/05.Prefabs/Spearman.prefab.meta
Normal file
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 71ae6cefbce980f49af048059733de89
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
BlueWater/Assets/06.Sounds.meta
Normal file
8
BlueWater/Assets/06.Sounds.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 445e4b771f240bf48a7304f176f2fbf8
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
BlueWater/Assets/07.Animation.meta
Normal file
8
BlueWater/Assets/07.Animation.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8fa7c5163d432e64bb6d40effde87349
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
11
BlueWater/Assets/07.Animation/AttackAvatarMask.mask
Normal file
11
BlueWater/Assets/07.Animation/AttackAvatarMask.mask
Normal file
@ -0,0 +1,11 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!319 &31900000
|
||||
AvatarMask:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: AttackAvatarMask
|
||||
m_Mask: 01000000010000000100000000000000000000000100000001000000010000000100000001000000010000000100000001000000
|
||||
m_Elements: []
|
8
BlueWater/Assets/07.Animation/AttackAvatarMask.mask.meta
Normal file
8
BlueWater/Assets/07.Animation/AttackAvatarMask.mask.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ad8fbe0bee0314f4b845e2f964358778
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 31900000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
651
BlueWater/Assets/07.Animation/Infantryman.controller
Normal file
651
BlueWater/Assets/07.Animation/Infantryman.controller
Normal file
@ -0,0 +1,651 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!206 &-9044354845508972843
|
||||
BlendTree:
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Blend Tree
|
||||
m_Childs:
|
||||
- serializedVersion: 2
|
||||
m_Motion: {fileID: 7400000, guid: d2fa6cc158d1d8e4da35dba21ab4395d, type: 3}
|
||||
m_Threshold: 0
|
||||
m_Position: {x: 0, y: 0}
|
||||
m_TimeScale: 1
|
||||
m_CycleOffset: 0
|
||||
m_DirectBlendParameter: Blend
|
||||
m_Mirror: 0
|
||||
- serializedVersion: 2
|
||||
m_Motion: {fileID: 7400000, guid: 30ea09f4973091c4d96cebd7c631b537, type: 3}
|
||||
m_Threshold: 0.1
|
||||
m_Position: {x: 0, y: 0}
|
||||
m_TimeScale: 1
|
||||
m_CycleOffset: 0
|
||||
m_DirectBlendParameter: Blend
|
||||
m_Mirror: 0
|
||||
- serializedVersion: 2
|
||||
m_Motion: {fileID: 7400000, guid: 0db21fc102c66a444a2d99ddd0c4168b, type: 3}
|
||||
m_Threshold: 1
|
||||
m_Position: {x: 0, y: 0}
|
||||
m_TimeScale: 1
|
||||
m_CycleOffset: 0
|
||||
m_DirectBlendParameter: Blend
|
||||
m_Mirror: 0
|
||||
m_BlendParameter: Speed
|
||||
m_BlendParameterY: Blend
|
||||
m_MinThreshold: 0
|
||||
m_MaxThreshold: 1
|
||||
m_UseAutomaticThresholds: 0
|
||||
m_NormalizedBlendValues: 0
|
||||
m_BlendType: 0
|
||||
--- !u!1102 &-8970947652927201876
|
||||
AnimatorState:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Idle
|
||||
m_Speed: 1
|
||||
m_CycleOffset: 0
|
||||
m_Transitions: []
|
||||
m_StateMachineBehaviours: []
|
||||
m_Position: {x: 50, y: 50, z: 0}
|
||||
m_IKOnFeet: 0
|
||||
m_WriteDefaultValues: 1
|
||||
m_Mirror: 0
|
||||
m_SpeedParameterActive: 0
|
||||
m_MirrorParameterActive: 0
|
||||
m_CycleOffsetParameterActive: 0
|
||||
m_TimeParameterActive: 0
|
||||
m_Motion: {fileID: 0}
|
||||
m_Tag:
|
||||
m_SpeedParameter:
|
||||
m_MirrorParameter:
|
||||
m_CycleOffsetParameter:
|
||||
m_TimeParameter:
|
||||
--- !u!1101 &-7854804674546960086
|
||||
AnimatorStateTransition:
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name:
|
||||
m_Conditions: []
|
||||
m_DstStateMachine: {fileID: 0}
|
||||
m_DstState: {fileID: 5304119996036113566}
|
||||
m_Solo: 0
|
||||
m_Mute: 0
|
||||
m_IsExit: 0
|
||||
serializedVersion: 3
|
||||
m_TransitionDuration: 0.25
|
||||
m_TransitionOffset: 0
|
||||
m_ExitTime: 0.625
|
||||
m_HasExitTime: 1
|
||||
m_HasFixedDuration: 1
|
||||
m_InterruptionSource: 0
|
||||
m_OrderedInterruption: 1
|
||||
m_CanTransitionToSelf: 1
|
||||
--- !u!1101 &-7488432702046877422
|
||||
AnimatorStateTransition:
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name:
|
||||
m_Conditions:
|
||||
- m_ConditionMode: 1
|
||||
m_ConditionEvent: TakeDamage
|
||||
m_EventTreshold: 0
|
||||
m_DstStateMachine: {fileID: 0}
|
||||
m_DstState: {fileID: -4719989283223396458}
|
||||
m_Solo: 0
|
||||
m_Mute: 0
|
||||
m_IsExit: 0
|
||||
serializedVersion: 3
|
||||
m_TransitionDuration: 0
|
||||
m_TransitionOffset: 0
|
||||
m_ExitTime: 0
|
||||
m_HasExitTime: 0
|
||||
m_HasFixedDuration: 1
|
||||
m_InterruptionSource: 0
|
||||
m_OrderedInterruption: 1
|
||||
m_CanTransitionToSelf: 1
|
||||
--- !u!1102 &-6677449554117134834
|
||||
AnimatorState:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: shield_06_death_B
|
||||
m_Speed: 1
|
||||
m_CycleOffset: 0
|
||||
m_Transitions: []
|
||||
m_StateMachineBehaviours: []
|
||||
m_Position: {x: 50, y: 50, z: 0}
|
||||
m_IKOnFeet: 0
|
||||
m_WriteDefaultValues: 1
|
||||
m_Mirror: 0
|
||||
m_SpeedParameterActive: 0
|
||||
m_MirrorParameterActive: 0
|
||||
m_CycleOffsetParameterActive: 0
|
||||
m_TimeParameterActive: 0
|
||||
m_Motion: {fileID: 7400000, guid: 2cd4c7fa9ab8728449da2d7730b71ac2, type: 3}
|
||||
m_Tag:
|
||||
m_SpeedParameter:
|
||||
m_MirrorParameter:
|
||||
m_CycleOffsetParameter:
|
||||
m_TimeParameter:
|
||||
--- !u!1102 &-5613045854842106462
|
||||
AnimatorState:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: shield_06_death_A
|
||||
m_Speed: 1
|
||||
m_CycleOffset: 0
|
||||
m_Transitions: []
|
||||
m_StateMachineBehaviours: []
|
||||
m_Position: {x: 50, y: 50, z: 0}
|
||||
m_IKOnFeet: 0
|
||||
m_WriteDefaultValues: 1
|
||||
m_Mirror: 0
|
||||
m_SpeedParameterActive: 0
|
||||
m_MirrorParameterActive: 0
|
||||
m_CycleOffsetParameterActive: 0
|
||||
m_TimeParameterActive: 0
|
||||
m_Motion: {fileID: 7400000, guid: 46cd827701fed424c817fee08823358d, type: 3}
|
||||
m_Tag:
|
||||
m_SpeedParameter:
|
||||
m_MirrorParameter:
|
||||
m_CycleOffsetParameter:
|
||||
m_TimeParameter:
|
||||
--- !u!1102 &-4719989283223396458
|
||||
AnimatorState:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: shield_05_damage
|
||||
m_Speed: 1
|
||||
m_CycleOffset: 0
|
||||
m_Transitions:
|
||||
- {fileID: -2853217596722282320}
|
||||
m_StateMachineBehaviours: []
|
||||
m_Position: {x: 50, y: 50, z: 0}
|
||||
m_IKOnFeet: 0
|
||||
m_WriteDefaultValues: 1
|
||||
m_Mirror: 0
|
||||
m_SpeedParameterActive: 0
|
||||
m_MirrorParameterActive: 0
|
||||
m_CycleOffsetParameterActive: 0
|
||||
m_TimeParameterActive: 0
|
||||
m_Motion: {fileID: 7400000, guid: dd91f49bb1870a843b0ce0e064e87045, type: 3}
|
||||
m_Tag:
|
||||
m_SpeedParameter:
|
||||
m_MirrorParameter:
|
||||
m_CycleOffsetParameter:
|
||||
m_TimeParameter:
|
||||
--- !u!1101 &-4045398789960513325
|
||||
AnimatorStateTransition:
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name:
|
||||
m_Conditions:
|
||||
- m_ConditionMode: 6
|
||||
m_ConditionEvent: AttackType
|
||||
m_EventTreshold: 1
|
||||
m_DstStateMachine: {fileID: 0}
|
||||
m_DstState: {fileID: 7758239304624801405}
|
||||
m_Solo: 0
|
||||
m_Mute: 0
|
||||
m_IsExit: 0
|
||||
serializedVersion: 3
|
||||
m_TransitionDuration: 0.25
|
||||
m_TransitionOffset: 0
|
||||
m_ExitTime: 0.8333334
|
||||
m_HasExitTime: 1
|
||||
m_HasFixedDuration: 1
|
||||
m_InterruptionSource: 0
|
||||
m_OrderedInterruption: 1
|
||||
m_CanTransitionToSelf: 1
|
||||
--- !u!1102 &-3262334696151519221
|
||||
AnimatorState:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: shield_04_attack_B
|
||||
m_Speed: 1
|
||||
m_CycleOffset: 0
|
||||
m_Transitions:
|
||||
- {fileID: -4045398789960513325}
|
||||
m_StateMachineBehaviours: []
|
||||
m_Position: {x: 50, y: 50, z: 0}
|
||||
m_IKOnFeet: 0
|
||||
m_WriteDefaultValues: 1
|
||||
m_Mirror: 0
|
||||
m_SpeedParameterActive: 0
|
||||
m_MirrorParameterActive: 0
|
||||
m_CycleOffsetParameterActive: 0
|
||||
m_TimeParameterActive: 0
|
||||
m_Motion: {fileID: 7400000, guid: 5a7200e1c2b48164d856cdab807a71bb, type: 3}
|
||||
m_Tag:
|
||||
m_SpeedParameter:
|
||||
m_MirrorParameter:
|
||||
m_CycleOffsetParameter:
|
||||
m_TimeParameter:
|
||||
--- !u!1101 &-2853217596722282320
|
||||
AnimatorStateTransition:
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name:
|
||||
m_Conditions: []
|
||||
m_DstStateMachine: {fileID: 0}
|
||||
m_DstState: {fileID: 7758239304624801405}
|
||||
m_Solo: 0
|
||||
m_Mute: 0
|
||||
m_IsExit: 0
|
||||
serializedVersion: 3
|
||||
m_TransitionDuration: 0.25
|
||||
m_TransitionOffset: 0
|
||||
m_ExitTime: 0.625
|
||||
m_HasExitTime: 1
|
||||
m_HasFixedDuration: 1
|
||||
m_InterruptionSource: 0
|
||||
m_OrderedInterruption: 1
|
||||
m_CanTransitionToSelf: 1
|
||||
--- !u!1102 &-1588768182804401634
|
||||
AnimatorState:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: shield_04_attack_A
|
||||
m_Speed: 1
|
||||
m_CycleOffset: 0
|
||||
m_Transitions:
|
||||
- {fileID: 3907710630580683776}
|
||||
m_StateMachineBehaviours: []
|
||||
m_Position: {x: 50, y: 50, z: 0}
|
||||
m_IKOnFeet: 0
|
||||
m_WriteDefaultValues: 1
|
||||
m_Mirror: 0
|
||||
m_SpeedParameterActive: 0
|
||||
m_MirrorParameterActive: 0
|
||||
m_CycleOffsetParameterActive: 0
|
||||
m_TimeParameterActive: 0
|
||||
m_Motion: {fileID: 7400000, guid: e8b6ae497645a274e98d76a6e407ce8b, type: 3}
|
||||
m_Tag:
|
||||
m_SpeedParameter:
|
||||
m_MirrorParameter:
|
||||
m_CycleOffsetParameter:
|
||||
m_TimeParameter:
|
||||
--- !u!1101 &-675634058516030415
|
||||
AnimatorStateTransition:
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name:
|
||||
m_Conditions:
|
||||
- m_ConditionMode: 6
|
||||
m_ConditionEvent: DeathType
|
||||
m_EventTreshold: 1
|
||||
- m_ConditionMode: 1
|
||||
m_ConditionEvent: Death
|
||||
m_EventTreshold: 0
|
||||
m_DstStateMachine: {fileID: 0}
|
||||
m_DstState: {fileID: -6677449554117134834}
|
||||
m_Solo: 0
|
||||
m_Mute: 0
|
||||
m_IsExit: 0
|
||||
serializedVersion: 3
|
||||
m_TransitionDuration: 0
|
||||
m_TransitionOffset: 0
|
||||
m_ExitTime: 0
|
||||
m_HasExitTime: 0
|
||||
m_HasFixedDuration: 1
|
||||
m_InterruptionSource: 0
|
||||
m_OrderedInterruption: 1
|
||||
m_CanTransitionToSelf: 1
|
||||
--- !u!91 &9100000
|
||||
AnimatorController:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Infantryman
|
||||
serializedVersion: 5
|
||||
m_AnimatorParameters:
|
||||
- m_Name: Speed
|
||||
m_Type: 1
|
||||
m_DefaultFloat: 0
|
||||
m_DefaultInt: 0
|
||||
m_DefaultBool: 0
|
||||
m_Controller: {fileID: 9100000}
|
||||
- m_Name: AttackType
|
||||
m_Type: 3
|
||||
m_DefaultFloat: 0
|
||||
m_DefaultInt: 0
|
||||
m_DefaultBool: 0
|
||||
m_Controller: {fileID: 9100000}
|
||||
- m_Name: DeathType
|
||||
m_Type: 3
|
||||
m_DefaultFloat: 0
|
||||
m_DefaultInt: 0
|
||||
m_DefaultBool: 0
|
||||
m_Controller: {fileID: 9100000}
|
||||
- m_Name: Attack
|
||||
m_Type: 9
|
||||
m_DefaultFloat: 0
|
||||
m_DefaultInt: 0
|
||||
m_DefaultBool: 0
|
||||
m_Controller: {fileID: 9100000}
|
||||
- m_Name: TakeDamage
|
||||
m_Type: 9
|
||||
m_DefaultFloat: 0
|
||||
m_DefaultInt: 0
|
||||
m_DefaultBool: 0
|
||||
m_Controller: {fileID: 9100000}
|
||||
- m_Name: Death
|
||||
m_Type: 9
|
||||
m_DefaultFloat: 0
|
||||
m_DefaultInt: 0
|
||||
m_DefaultBool: 0
|
||||
m_Controller: {fileID: 9100000}
|
||||
m_AnimatorLayers:
|
||||
- serializedVersion: 5
|
||||
m_Name: Base
|
||||
m_StateMachine: {fileID: 167278188283925338}
|
||||
m_Mask: {fileID: 0}
|
||||
m_Motions: []
|
||||
m_Behaviours: []
|
||||
m_BlendingMode: 0
|
||||
m_SyncedLayerIndex: -1
|
||||
m_DefaultWeight: 0
|
||||
m_IKPass: 0
|
||||
m_SyncedLayerAffectsTiming: 0
|
||||
m_Controller: {fileID: 9100000}
|
||||
- serializedVersion: 5
|
||||
m_Name: UpperBody
|
||||
m_StateMachine: {fileID: 1014360538280732316}
|
||||
m_Mask: {fileID: 31900000, guid: ad8fbe0bee0314f4b845e2f964358778, type: 2}
|
||||
m_Motions: []
|
||||
m_Behaviours: []
|
||||
m_BlendingMode: 0
|
||||
m_SyncedLayerIndex: -1
|
||||
m_DefaultWeight: 1
|
||||
m_IKPass: 0
|
||||
m_SyncedLayerAffectsTiming: 0
|
||||
m_Controller: {fileID: 9100000}
|
||||
- serializedVersion: 5
|
||||
m_Name: FullBody
|
||||
m_StateMachine: {fileID: 7414727892699424751}
|
||||
m_Mask: {fileID: 0}
|
||||
m_Motions: []
|
||||
m_Behaviours: []
|
||||
m_BlendingMode: 0
|
||||
m_SyncedLayerIndex: -1
|
||||
m_DefaultWeight: 1
|
||||
m_IKPass: 0
|
||||
m_SyncedLayerAffectsTiming: 0
|
||||
m_Controller: {fileID: 9100000}
|
||||
--- !u!1107 &167278188283925338
|
||||
AnimatorStateMachine:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Base
|
||||
m_ChildStates:
|
||||
- serializedVersion: 1
|
||||
m_State: {fileID: 5304119996036113566}
|
||||
m_Position: {x: 360, y: 110, z: 0}
|
||||
m_ChildStateMachines: []
|
||||
m_AnyStateTransitions: []
|
||||
m_EntryTransitions: []
|
||||
m_StateMachineTransitions: {}
|
||||
m_StateMachineBehaviours: []
|
||||
m_AnyStatePosition: {x: 170, y: -30, z: 0}
|
||||
m_EntryPosition: {x: 50, y: 120, z: 0}
|
||||
m_ExitPosition: {x: 610, y: -10, z: 0}
|
||||
m_ParentStateMachinePosition: {x: 800, y: 20, z: 0}
|
||||
m_DefaultState: {fileID: 5304119996036113566}
|
||||
--- !u!1101 &301483702199899037
|
||||
AnimatorStateTransition:
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name:
|
||||
m_Conditions:
|
||||
- m_ConditionMode: 6
|
||||
m_ConditionEvent: AttackType
|
||||
m_EventTreshold: 0
|
||||
- m_ConditionMode: 1
|
||||
m_ConditionEvent: Attack
|
||||
m_EventTreshold: 0
|
||||
m_DstStateMachine: {fileID: 0}
|
||||
m_DstState: {fileID: -1588768182804401634}
|
||||
m_Solo: 0
|
||||
m_Mute: 0
|
||||
m_IsExit: 0
|
||||
serializedVersion: 3
|
||||
m_TransitionDuration: 0
|
||||
m_TransitionOffset: 0
|
||||
m_ExitTime: 0
|
||||
m_HasExitTime: 0
|
||||
m_HasFixedDuration: 1
|
||||
m_InterruptionSource: 0
|
||||
m_OrderedInterruption: 1
|
||||
m_CanTransitionToSelf: 1
|
||||
--- !u!1107 &1014360538280732316
|
||||
AnimatorStateMachine:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: UpperBody
|
||||
m_ChildStates:
|
||||
- serializedVersion: 1
|
||||
m_State: {fileID: 7758239304624801405}
|
||||
m_Position: {x: 380, y: 120, z: 0}
|
||||
- serializedVersion: 1
|
||||
m_State: {fileID: -1588768182804401634}
|
||||
m_Position: {x: 260, y: 260, z: 0}
|
||||
- serializedVersion: 1
|
||||
m_State: {fileID: -3262334696151519221}
|
||||
m_Position: {x: 570, y: 260, z: 0}
|
||||
- serializedVersion: 1
|
||||
m_State: {fileID: -4719989283223396458}
|
||||
m_Position: {x: 310, y: 10, z: 0}
|
||||
m_ChildStateMachines: []
|
||||
m_AnyStateTransitions:
|
||||
- {fileID: -7488432702046877422}
|
||||
m_EntryTransitions: []
|
||||
m_StateMachineTransitions: {}
|
||||
m_StateMachineBehaviours: []
|
||||
m_AnyStatePosition: {x: 50, y: 20, z: 0}
|
||||
m_EntryPosition: {x: 50, y: 120, z: 0}
|
||||
m_ExitPosition: {x: 800, y: 120, z: 0}
|
||||
m_ParentStateMachinePosition: {x: 800, y: 20, z: 0}
|
||||
m_DefaultState: {fileID: 7758239304624801405}
|
||||
--- !u!1101 &3907710630580683776
|
||||
AnimatorStateTransition:
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name:
|
||||
m_Conditions:
|
||||
- m_ConditionMode: 6
|
||||
m_ConditionEvent: AttackType
|
||||
m_EventTreshold: 0
|
||||
m_DstStateMachine: {fileID: 0}
|
||||
m_DstState: {fileID: 7758239304624801405}
|
||||
m_Solo: 0
|
||||
m_Mute: 0
|
||||
m_IsExit: 0
|
||||
serializedVersion: 3
|
||||
m_TransitionDuration: 0.25
|
||||
m_TransitionOffset: 0
|
||||
m_ExitTime: 0.8333334
|
||||
m_HasExitTime: 1
|
||||
m_HasFixedDuration: 1
|
||||
m_InterruptionSource: 0
|
||||
m_OrderedInterruption: 1
|
||||
m_CanTransitionToSelf: 1
|
||||
--- !u!1102 &5304119996036113566
|
||||
AnimatorState:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Blend Tree
|
||||
m_Speed: 1
|
||||
m_CycleOffset: 0
|
||||
m_Transitions: []
|
||||
m_StateMachineBehaviours: []
|
||||
m_Position: {x: 50, y: 50, z: 0}
|
||||
m_IKOnFeet: 0
|
||||
m_WriteDefaultValues: 1
|
||||
m_Mirror: 0
|
||||
m_SpeedParameterActive: 0
|
||||
m_MirrorParameterActive: 0
|
||||
m_CycleOffsetParameterActive: 0
|
||||
m_TimeParameterActive: 0
|
||||
m_Motion: {fileID: -9044354845508972843}
|
||||
m_Tag:
|
||||
m_SpeedParameter:
|
||||
m_MirrorParameter:
|
||||
m_CycleOffsetParameter:
|
||||
m_TimeParameter:
|
||||
--- !u!1101 &5378458499681276728
|
||||
AnimatorStateTransition:
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name:
|
||||
m_Conditions:
|
||||
- m_ConditionMode: 6
|
||||
m_ConditionEvent: DeathType
|
||||
m_EventTreshold: 0
|
||||
- m_ConditionMode: 1
|
||||
m_ConditionEvent: Death
|
||||
m_EventTreshold: 0
|
||||
m_DstStateMachine: {fileID: 0}
|
||||
m_DstState: {fileID: -5613045854842106462}
|
||||
m_Solo: 0
|
||||
m_Mute: 0
|
||||
m_IsExit: 0
|
||||
serializedVersion: 3
|
||||
m_TransitionDuration: 0
|
||||
m_TransitionOffset: 0
|
||||
m_ExitTime: 0
|
||||
m_HasExitTime: 0
|
||||
m_HasFixedDuration: 1
|
||||
m_InterruptionSource: 0
|
||||
m_OrderedInterruption: 1
|
||||
m_CanTransitionToSelf: 1
|
||||
--- !u!1101 &7243255047482691604
|
||||
AnimatorStateTransition:
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name:
|
||||
m_Conditions:
|
||||
- m_ConditionMode: 6
|
||||
m_ConditionEvent: AttackType
|
||||
m_EventTreshold: 1
|
||||
- m_ConditionMode: 1
|
||||
m_ConditionEvent: Attack
|
||||
m_EventTreshold: 0
|
||||
m_DstStateMachine: {fileID: 0}
|
||||
m_DstState: {fileID: -3262334696151519221}
|
||||
m_Solo: 0
|
||||
m_Mute: 0
|
||||
m_IsExit: 0
|
||||
serializedVersion: 3
|
||||
m_TransitionDuration: 0
|
||||
m_TransitionOffset: 0
|
||||
m_ExitTime: 0
|
||||
m_HasExitTime: 0
|
||||
m_HasFixedDuration: 1
|
||||
m_InterruptionSource: 0
|
||||
m_OrderedInterruption: 1
|
||||
m_CanTransitionToSelf: 1
|
||||
--- !u!1107 &7414727892699424751
|
||||
AnimatorStateMachine:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: FullBody
|
||||
m_ChildStates:
|
||||
- serializedVersion: 1
|
||||
m_State: {fileID: -6677449554117134834}
|
||||
m_Position: {x: 360, y: 20, z: 0}
|
||||
- serializedVersion: 1
|
||||
m_State: {fileID: -5613045854842106462}
|
||||
m_Position: {x: 360, y: -30, z: 0}
|
||||
- serializedVersion: 1
|
||||
m_State: {fileID: -8970947652927201876}
|
||||
m_Position: {x: 400, y: 140, z: 0}
|
||||
m_ChildStateMachines: []
|
||||
m_AnyStateTransitions:
|
||||
- {fileID: 5378458499681276728}
|
||||
- {fileID: -675634058516030415}
|
||||
m_EntryTransitions: []
|
||||
m_StateMachineTransitions: {}
|
||||
m_StateMachineBehaviours: []
|
||||
m_AnyStatePosition: {x: 50, y: 20, z: 0}
|
||||
m_EntryPosition: {x: 60, y: 140, z: 0}
|
||||
m_ExitPosition: {x: 800, y: 120, z: 0}
|
||||
m_ParentStateMachinePosition: {x: 800, y: 20, z: 0}
|
||||
m_DefaultState: {fileID: -8970947652927201876}
|
||||
--- !u!1102 &7758239304624801405
|
||||
AnimatorState:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Idle
|
||||
m_Speed: 1
|
||||
m_CycleOffset: 0
|
||||
m_Transitions:
|
||||
- {fileID: 301483702199899037}
|
||||
- {fileID: 7243255047482691604}
|
||||
m_StateMachineBehaviours: []
|
||||
m_Position: {x: 50, y: 50, z: 0}
|
||||
m_IKOnFeet: 0
|
||||
m_WriteDefaultValues: 1
|
||||
m_Mirror: 0
|
||||
m_SpeedParameterActive: 0
|
||||
m_MirrorParameterActive: 0
|
||||
m_CycleOffsetParameterActive: 0
|
||||
m_TimeParameterActive: 0
|
||||
m_Motion: {fileID: 0}
|
||||
m_Tag:
|
||||
m_SpeedParameter:
|
||||
m_MirrorParameter:
|
||||
m_CycleOffsetParameter:
|
||||
m_TimeParameter:
|
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: aca0db2952a1e6e4d84c9551f29c5b3e
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 9100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
651
BlueWater/Assets/07.Animation/Scout.controller
Normal file
651
BlueWater/Assets/07.Animation/Scout.controller
Normal file
@ -0,0 +1,651 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!206 &-9044354845508972843
|
||||
BlendTree:
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Blend Tree
|
||||
m_Childs:
|
||||
- serializedVersion: 2
|
||||
m_Motion: {fileID: 7400000, guid: 0527e149cc2c97f4d8400a454a21e9d6, type: 3}
|
||||
m_Threshold: 0
|
||||
m_Position: {x: 0, y: 0}
|
||||
m_TimeScale: 1
|
||||
m_CycleOffset: 0
|
||||
m_DirectBlendParameter: Blend
|
||||
m_Mirror: 0
|
||||
- serializedVersion: 2
|
||||
m_Motion: {fileID: 7400000, guid: aabc35eaaa658c747ba58b7ede30f77c, type: 3}
|
||||
m_Threshold: 0.1
|
||||
m_Position: {x: 0, y: 0}
|
||||
m_TimeScale: 1
|
||||
m_CycleOffset: 0
|
||||
m_DirectBlendParameter: Blend
|
||||
m_Mirror: 0
|
||||
- serializedVersion: 2
|
||||
m_Motion: {fileID: 7400000, guid: 57f4b6d8e4aaa67469ac9e22f15acb33, type: 3}
|
||||
m_Threshold: 1
|
||||
m_Position: {x: 0, y: 0}
|
||||
m_TimeScale: 1
|
||||
m_CycleOffset: 0
|
||||
m_DirectBlendParameter: Blend
|
||||
m_Mirror: 0
|
||||
m_BlendParameter: Speed
|
||||
m_BlendParameterY: Blend
|
||||
m_MinThreshold: 0
|
||||
m_MaxThreshold: 1
|
||||
m_UseAutomaticThresholds: 0
|
||||
m_NormalizedBlendValues: 0
|
||||
m_BlendType: 0
|
||||
--- !u!1102 &-8970947652927201876
|
||||
AnimatorState:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Idle
|
||||
m_Speed: 1
|
||||
m_CycleOffset: 0
|
||||
m_Transitions: []
|
||||
m_StateMachineBehaviours: []
|
||||
m_Position: {x: 50, y: 50, z: 0}
|
||||
m_IKOnFeet: 0
|
||||
m_WriteDefaultValues: 1
|
||||
m_Mirror: 0
|
||||
m_SpeedParameterActive: 0
|
||||
m_MirrorParameterActive: 0
|
||||
m_CycleOffsetParameterActive: 0
|
||||
m_TimeParameterActive: 0
|
||||
m_Motion: {fileID: 0}
|
||||
m_Tag:
|
||||
m_SpeedParameter:
|
||||
m_MirrorParameter:
|
||||
m_CycleOffsetParameter:
|
||||
m_TimeParameter:
|
||||
--- !u!1101 &-7854804674546960086
|
||||
AnimatorStateTransition:
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name:
|
||||
m_Conditions: []
|
||||
m_DstStateMachine: {fileID: 0}
|
||||
m_DstState: {fileID: 5304119996036113566}
|
||||
m_Solo: 0
|
||||
m_Mute: 0
|
||||
m_IsExit: 0
|
||||
serializedVersion: 3
|
||||
m_TransitionDuration: 0.25
|
||||
m_TransitionOffset: 0
|
||||
m_ExitTime: 0.625
|
||||
m_HasExitTime: 1
|
||||
m_HasFixedDuration: 1
|
||||
m_InterruptionSource: 0
|
||||
m_OrderedInterruption: 1
|
||||
m_CanTransitionToSelf: 1
|
||||
--- !u!1101 &-7488432702046877422
|
||||
AnimatorStateTransition:
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name:
|
||||
m_Conditions:
|
||||
- m_ConditionMode: 1
|
||||
m_ConditionEvent: TakeDamage
|
||||
m_EventTreshold: 0
|
||||
m_DstStateMachine: {fileID: 0}
|
||||
m_DstState: {fileID: -4719989283223396458}
|
||||
m_Solo: 0
|
||||
m_Mute: 0
|
||||
m_IsExit: 0
|
||||
serializedVersion: 3
|
||||
m_TransitionDuration: 0
|
||||
m_TransitionOffset: 0
|
||||
m_ExitTime: 0
|
||||
m_HasExitTime: 0
|
||||
m_HasFixedDuration: 1
|
||||
m_InterruptionSource: 0
|
||||
m_OrderedInterruption: 1
|
||||
m_CanTransitionToSelf: 1
|
||||
--- !u!1102 &-6677449554117134834
|
||||
AnimatorState:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: archer_06_death_B
|
||||
m_Speed: 1
|
||||
m_CycleOffset: 0
|
||||
m_Transitions: []
|
||||
m_StateMachineBehaviours: []
|
||||
m_Position: {x: 50, y: 50, z: 0}
|
||||
m_IKOnFeet: 0
|
||||
m_WriteDefaultValues: 1
|
||||
m_Mirror: 0
|
||||
m_SpeedParameterActive: 0
|
||||
m_MirrorParameterActive: 0
|
||||
m_CycleOffsetParameterActive: 0
|
||||
m_TimeParameterActive: 0
|
||||
m_Motion: {fileID: 7400000, guid: edb2cc99c5715234c8cc28ec7ed91695, type: 3}
|
||||
m_Tag:
|
||||
m_SpeedParameter:
|
||||
m_MirrorParameter:
|
||||
m_CycleOffsetParameter:
|
||||
m_TimeParameter:
|
||||
--- !u!1102 &-5613045854842106462
|
||||
AnimatorState:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: archer_06_death_A
|
||||
m_Speed: 1
|
||||
m_CycleOffset: 0
|
||||
m_Transitions: []
|
||||
m_StateMachineBehaviours: []
|
||||
m_Position: {x: 50, y: 50, z: 0}
|
||||
m_IKOnFeet: 0
|
||||
m_WriteDefaultValues: 1
|
||||
m_Mirror: 0
|
||||
m_SpeedParameterActive: 0
|
||||
m_MirrorParameterActive: 0
|
||||
m_CycleOffsetParameterActive: 0
|
||||
m_TimeParameterActive: 0
|
||||
m_Motion: {fileID: 7400000, guid: a70ccc875bd2f254293e91baaad644f9, type: 3}
|
||||
m_Tag:
|
||||
m_SpeedParameter:
|
||||
m_MirrorParameter:
|
||||
m_CycleOffsetParameter:
|
||||
m_TimeParameter:
|
||||
--- !u!1102 &-4719989283223396458
|
||||
AnimatorState:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: archer_05_damage
|
||||
m_Speed: 1
|
||||
m_CycleOffset: 0
|
||||
m_Transitions:
|
||||
- {fileID: -2853217596722282320}
|
||||
m_StateMachineBehaviours: []
|
||||
m_Position: {x: 50, y: 50, z: 0}
|
||||
m_IKOnFeet: 0
|
||||
m_WriteDefaultValues: 1
|
||||
m_Mirror: 0
|
||||
m_SpeedParameterActive: 0
|
||||
m_MirrorParameterActive: 0
|
||||
m_CycleOffsetParameterActive: 0
|
||||
m_TimeParameterActive: 0
|
||||
m_Motion: {fileID: 7400000, guid: 0a4e8acfb75e3654db0973b4d502fdee, type: 3}
|
||||
m_Tag:
|
||||
m_SpeedParameter:
|
||||
m_MirrorParameter:
|
||||
m_CycleOffsetParameter:
|
||||
m_TimeParameter:
|
||||
--- !u!1101 &-4045398789960513325
|
||||
AnimatorStateTransition:
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name:
|
||||
m_Conditions:
|
||||
- m_ConditionMode: 6
|
||||
m_ConditionEvent: AttackType
|
||||
m_EventTreshold: 1
|
||||
m_DstStateMachine: {fileID: 0}
|
||||
m_DstState: {fileID: 7758239304624801405}
|
||||
m_Solo: 0
|
||||
m_Mute: 0
|
||||
m_IsExit: 0
|
||||
serializedVersion: 3
|
||||
m_TransitionDuration: 0.25
|
||||
m_TransitionOffset: 0
|
||||
m_ExitTime: 0.8333334
|
||||
m_HasExitTime: 1
|
||||
m_HasFixedDuration: 1
|
||||
m_InterruptionSource: 0
|
||||
m_OrderedInterruption: 1
|
||||
m_CanTransitionToSelf: 1
|
||||
--- !u!1102 &-3262334696151519221
|
||||
AnimatorState:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: archer_04_attack_B
|
||||
m_Speed: 1
|
||||
m_CycleOffset: 0
|
||||
m_Transitions:
|
||||
- {fileID: -4045398789960513325}
|
||||
m_StateMachineBehaviours: []
|
||||
m_Position: {x: 50, y: 50, z: 0}
|
||||
m_IKOnFeet: 0
|
||||
m_WriteDefaultValues: 1
|
||||
m_Mirror: 0
|
||||
m_SpeedParameterActive: 0
|
||||
m_MirrorParameterActive: 0
|
||||
m_CycleOffsetParameterActive: 0
|
||||
m_TimeParameterActive: 0
|
||||
m_Motion: {fileID: 7400000, guid: 5142e855d0214a64fa6432eafc50a2d0, type: 3}
|
||||
m_Tag:
|
||||
m_SpeedParameter:
|
||||
m_MirrorParameter:
|
||||
m_CycleOffsetParameter:
|
||||
m_TimeParameter:
|
||||
--- !u!1101 &-2853217596722282320
|
||||
AnimatorStateTransition:
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name:
|
||||
m_Conditions: []
|
||||
m_DstStateMachine: {fileID: 0}
|
||||
m_DstState: {fileID: 7758239304624801405}
|
||||
m_Solo: 0
|
||||
m_Mute: 0
|
||||
m_IsExit: 0
|
||||
serializedVersion: 3
|
||||
m_TransitionDuration: 0.25
|
||||
m_TransitionOffset: 0
|
||||
m_ExitTime: 0.625
|
||||
m_HasExitTime: 1
|
||||
m_HasFixedDuration: 1
|
||||
m_InterruptionSource: 0
|
||||
m_OrderedInterruption: 1
|
||||
m_CanTransitionToSelf: 1
|
||||
--- !u!1102 &-1588768182804401634
|
||||
AnimatorState:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: archer_04_attack_A
|
||||
m_Speed: 1
|
||||
m_CycleOffset: 0
|
||||
m_Transitions:
|
||||
- {fileID: 3907710630580683776}
|
||||
m_StateMachineBehaviours: []
|
||||
m_Position: {x: 50, y: 50, z: 0}
|
||||
m_IKOnFeet: 0
|
||||
m_WriteDefaultValues: 1
|
||||
m_Mirror: 0
|
||||
m_SpeedParameterActive: 0
|
||||
m_MirrorParameterActive: 0
|
||||
m_CycleOffsetParameterActive: 0
|
||||
m_TimeParameterActive: 0
|
||||
m_Motion: {fileID: 7400000, guid: 2f2a39086989dc44b8d626d1c663ed0d, type: 3}
|
||||
m_Tag:
|
||||
m_SpeedParameter:
|
||||
m_MirrorParameter:
|
||||
m_CycleOffsetParameter:
|
||||
m_TimeParameter:
|
||||
--- !u!1101 &-675634058516030415
|
||||
AnimatorStateTransition:
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name:
|
||||
m_Conditions:
|
||||
- m_ConditionMode: 6
|
||||
m_ConditionEvent: DeathType
|
||||
m_EventTreshold: 1
|
||||
- m_ConditionMode: 1
|
||||
m_ConditionEvent: Death
|
||||
m_EventTreshold: 0
|
||||
m_DstStateMachine: {fileID: 0}
|
||||
m_DstState: {fileID: -6677449554117134834}
|
||||
m_Solo: 0
|
||||
m_Mute: 0
|
||||
m_IsExit: 0
|
||||
serializedVersion: 3
|
||||
m_TransitionDuration: 0
|
||||
m_TransitionOffset: 0
|
||||
m_ExitTime: 0
|
||||
m_HasExitTime: 0
|
||||
m_HasFixedDuration: 1
|
||||
m_InterruptionSource: 0
|
||||
m_OrderedInterruption: 1
|
||||
m_CanTransitionToSelf: 1
|
||||
--- !u!91 &9100000
|
||||
AnimatorController:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Scout
|
||||
serializedVersion: 5
|
||||
m_AnimatorParameters:
|
||||
- m_Name: Speed
|
||||
m_Type: 1
|
||||
m_DefaultFloat: 0
|
||||
m_DefaultInt: 0
|
||||
m_DefaultBool: 0
|
||||
m_Controller: {fileID: 9100000}
|
||||
- m_Name: AttackType
|
||||
m_Type: 3
|
||||
m_DefaultFloat: 0
|
||||
m_DefaultInt: 0
|
||||
m_DefaultBool: 0
|
||||
m_Controller: {fileID: 9100000}
|
||||
- m_Name: DeathType
|
||||
m_Type: 3
|
||||
m_DefaultFloat: 0
|
||||
m_DefaultInt: 0
|
||||
m_DefaultBool: 0
|
||||
m_Controller: {fileID: 9100000}
|
||||
- m_Name: Attack
|
||||
m_Type: 9
|
||||
m_DefaultFloat: 0
|
||||
m_DefaultInt: 0
|
||||
m_DefaultBool: 0
|
||||
m_Controller: {fileID: 9100000}
|
||||
- m_Name: TakeDamage
|
||||
m_Type: 9
|
||||
m_DefaultFloat: 0
|
||||
m_DefaultInt: 0
|
||||
m_DefaultBool: 0
|
||||
m_Controller: {fileID: 9100000}
|
||||
- m_Name: Death
|
||||
m_Type: 9
|
||||
m_DefaultFloat: 0
|
||||
m_DefaultInt: 0
|
||||
m_DefaultBool: 0
|
||||
m_Controller: {fileID: 9100000}
|
||||
m_AnimatorLayers:
|
||||
- serializedVersion: 5
|
||||
m_Name: Base
|
||||
m_StateMachine: {fileID: 167278188283925338}
|
||||
m_Mask: {fileID: 0}
|
||||
m_Motions: []
|
||||
m_Behaviours: []
|
||||
m_BlendingMode: 0
|
||||
m_SyncedLayerIndex: -1
|
||||
m_DefaultWeight: 0
|
||||
m_IKPass: 0
|
||||
m_SyncedLayerAffectsTiming: 0
|
||||
m_Controller: {fileID: 9100000}
|
||||
- serializedVersion: 5
|
||||
m_Name: UpperBody
|
||||
m_StateMachine: {fileID: 1014360538280732316}
|
||||
m_Mask: {fileID: 31900000, guid: ad8fbe0bee0314f4b845e2f964358778, type: 2}
|
||||
m_Motions: []
|
||||
m_Behaviours: []
|
||||
m_BlendingMode: 0
|
||||
m_SyncedLayerIndex: -1
|
||||
m_DefaultWeight: 1
|
||||
m_IKPass: 0
|
||||
m_SyncedLayerAffectsTiming: 0
|
||||
m_Controller: {fileID: 9100000}
|
||||
- serializedVersion: 5
|
||||
m_Name: FullBody
|
||||
m_StateMachine: {fileID: 7414727892699424751}
|
||||
m_Mask: {fileID: 0}
|
||||
m_Motions: []
|
||||
m_Behaviours: []
|
||||
m_BlendingMode: 0
|
||||
m_SyncedLayerIndex: -1
|
||||
m_DefaultWeight: 1
|
||||
m_IKPass: 0
|
||||
m_SyncedLayerAffectsTiming: 0
|
||||
m_Controller: {fileID: 9100000}
|
||||
--- !u!1107 &167278188283925338
|
||||
AnimatorStateMachine:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Base
|
||||
m_ChildStates:
|
||||
- serializedVersion: 1
|
||||
m_State: {fileID: 5304119996036113566}
|
||||
m_Position: {x: 360, y: 110, z: 0}
|
||||
m_ChildStateMachines: []
|
||||
m_AnyStateTransitions: []
|
||||
m_EntryTransitions: []
|
||||
m_StateMachineTransitions: {}
|
||||
m_StateMachineBehaviours: []
|
||||
m_AnyStatePosition: {x: 170, y: -30, z: 0}
|
||||
m_EntryPosition: {x: 50, y: 120, z: 0}
|
||||
m_ExitPosition: {x: 610, y: -10, z: 0}
|
||||
m_ParentStateMachinePosition: {x: 800, y: 20, z: 0}
|
||||
m_DefaultState: {fileID: 5304119996036113566}
|
||||
--- !u!1101 &301483702199899037
|
||||
AnimatorStateTransition:
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name:
|
||||
m_Conditions:
|
||||
- m_ConditionMode: 6
|
||||
m_ConditionEvent: AttackType
|
||||
m_EventTreshold: 0
|
||||
- m_ConditionMode: 1
|
||||
m_ConditionEvent: Attack
|
||||
m_EventTreshold: 0
|
||||
m_DstStateMachine: {fileID: 0}
|
||||
m_DstState: {fileID: -1588768182804401634}
|
||||
m_Solo: 0
|
||||
m_Mute: 0
|
||||
m_IsExit: 0
|
||||
serializedVersion: 3
|
||||
m_TransitionDuration: 0
|
||||
m_TransitionOffset: 0
|
||||
m_ExitTime: 0
|
||||
m_HasExitTime: 0
|
||||
m_HasFixedDuration: 1
|
||||
m_InterruptionSource: 0
|
||||
m_OrderedInterruption: 1
|
||||
m_CanTransitionToSelf: 1
|
||||
--- !u!1107 &1014360538280732316
|
||||
AnimatorStateMachine:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: UpperBody
|
||||
m_ChildStates:
|
||||
- serializedVersion: 1
|
||||
m_State: {fileID: 7758239304624801405}
|
||||
m_Position: {x: 380, y: 120, z: 0}
|
||||
- serializedVersion: 1
|
||||
m_State: {fileID: -1588768182804401634}
|
||||
m_Position: {x: 260, y: 260, z: 0}
|
||||
- serializedVersion: 1
|
||||
m_State: {fileID: -3262334696151519221}
|
||||
m_Position: {x: 570, y: 260, z: 0}
|
||||
- serializedVersion: 1
|
||||
m_State: {fileID: -4719989283223396458}
|
||||
m_Position: {x: 310, y: 10, z: 0}
|
||||
m_ChildStateMachines: []
|
||||
m_AnyStateTransitions:
|
||||
- {fileID: -7488432702046877422}
|
||||
m_EntryTransitions: []
|
||||
m_StateMachineTransitions: {}
|
||||
m_StateMachineBehaviours: []
|
||||
m_AnyStatePosition: {x: 50, y: 20, z: 0}
|
||||
m_EntryPosition: {x: 50, y: 120, z: 0}
|
||||
m_ExitPosition: {x: 800, y: 120, z: 0}
|
||||
m_ParentStateMachinePosition: {x: 800, y: 20, z: 0}
|
||||
m_DefaultState: {fileID: 7758239304624801405}
|
||||
--- !u!1101 &3907710630580683776
|
||||
AnimatorStateTransition:
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name:
|
||||
m_Conditions:
|
||||
- m_ConditionMode: 6
|
||||
m_ConditionEvent: AttackType
|
||||
m_EventTreshold: 0
|
||||
m_DstStateMachine: {fileID: 0}
|
||||
m_DstState: {fileID: 7758239304624801405}
|
||||
m_Solo: 0
|
||||
m_Mute: 0
|
||||
m_IsExit: 0
|
||||
serializedVersion: 3
|
||||
m_TransitionDuration: 0.25
|
||||
m_TransitionOffset: 0
|
||||
m_ExitTime: 0.8333334
|
||||
m_HasExitTime: 1
|
||||
m_HasFixedDuration: 1
|
||||
m_InterruptionSource: 0
|
||||
m_OrderedInterruption: 1
|
||||
m_CanTransitionToSelf: 1
|
||||
--- !u!1102 &5304119996036113566
|
||||
AnimatorState:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Blend Tree
|
||||
m_Speed: 1
|
||||
m_CycleOffset: 0
|
||||
m_Transitions: []
|
||||
m_StateMachineBehaviours: []
|
||||
m_Position: {x: 50, y: 50, z: 0}
|
||||
m_IKOnFeet: 0
|
||||
m_WriteDefaultValues: 1
|
||||
m_Mirror: 0
|
||||
m_SpeedParameterActive: 0
|
||||
m_MirrorParameterActive: 0
|
||||
m_CycleOffsetParameterActive: 0
|
||||
m_TimeParameterActive: 0
|
||||
m_Motion: {fileID: -9044354845508972843}
|
||||
m_Tag:
|
||||
m_SpeedParameter:
|
||||
m_MirrorParameter:
|
||||
m_CycleOffsetParameter:
|
||||
m_TimeParameter:
|
||||
--- !u!1101 &5378458499681276728
|
||||
AnimatorStateTransition:
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name:
|
||||
m_Conditions:
|
||||
- m_ConditionMode: 6
|
||||
m_ConditionEvent: DeathType
|
||||
m_EventTreshold: 0
|
||||
- m_ConditionMode: 1
|
||||
m_ConditionEvent: Death
|
||||
m_EventTreshold: 0
|
||||
m_DstStateMachine: {fileID: 0}
|
||||
m_DstState: {fileID: -5613045854842106462}
|
||||
m_Solo: 0
|
||||
m_Mute: 0
|
||||
m_IsExit: 0
|
||||
serializedVersion: 3
|
||||
m_TransitionDuration: 0
|
||||
m_TransitionOffset: 0
|
||||
m_ExitTime: 0
|
||||
m_HasExitTime: 0
|
||||
m_HasFixedDuration: 1
|
||||
m_InterruptionSource: 0
|
||||
m_OrderedInterruption: 1
|
||||
m_CanTransitionToSelf: 1
|
||||
--- !u!1101 &7243255047482691604
|
||||
AnimatorStateTransition:
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name:
|
||||
m_Conditions:
|
||||
- m_ConditionMode: 6
|
||||
m_ConditionEvent: AttackType
|
||||
m_EventTreshold: 1
|
||||
- m_ConditionMode: 1
|
||||
m_ConditionEvent: Attack
|
||||
m_EventTreshold: 0
|
||||
m_DstStateMachine: {fileID: 0}
|
||||
m_DstState: {fileID: -3262334696151519221}
|
||||
m_Solo: 0
|
||||
m_Mute: 0
|
||||
m_IsExit: 0
|
||||
serializedVersion: 3
|
||||
m_TransitionDuration: 0
|
||||
m_TransitionOffset: 0
|
||||
m_ExitTime: 0
|
||||
m_HasExitTime: 0
|
||||
m_HasFixedDuration: 1
|
||||
m_InterruptionSource: 0
|
||||
m_OrderedInterruption: 1
|
||||
m_CanTransitionToSelf: 1
|
||||
--- !u!1107 &7414727892699424751
|
||||
AnimatorStateMachine:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: FullBody
|
||||
m_ChildStates:
|
||||
- serializedVersion: 1
|
||||
m_State: {fileID: -6677449554117134834}
|
||||
m_Position: {x: 360, y: 20, z: 0}
|
||||
- serializedVersion: 1
|
||||
m_State: {fileID: -5613045854842106462}
|
||||
m_Position: {x: 360, y: -30, z: 0}
|
||||
- serializedVersion: 1
|
||||
m_State: {fileID: -8970947652927201876}
|
||||
m_Position: {x: 400, y: 140, z: 0}
|
||||
m_ChildStateMachines: []
|
||||
m_AnyStateTransitions:
|
||||
- {fileID: 5378458499681276728}
|
||||
- {fileID: -675634058516030415}
|
||||
m_EntryTransitions: []
|
||||
m_StateMachineTransitions: {}
|
||||
m_StateMachineBehaviours: []
|
||||
m_AnyStatePosition: {x: 50, y: 20, z: 0}
|
||||
m_EntryPosition: {x: 60, y: 140, z: 0}
|
||||
m_ExitPosition: {x: 800, y: 120, z: 0}
|
||||
m_ParentStateMachinePosition: {x: 800, y: 20, z: 0}
|
||||
m_DefaultState: {fileID: -8970947652927201876}
|
||||
--- !u!1102 &7758239304624801405
|
||||
AnimatorState:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Idle
|
||||
m_Speed: 1
|
||||
m_CycleOffset: 0
|
||||
m_Transitions:
|
||||
- {fileID: 301483702199899037}
|
||||
- {fileID: 7243255047482691604}
|
||||
m_StateMachineBehaviours: []
|
||||
m_Position: {x: 50, y: 50, z: 0}
|
||||
m_IKOnFeet: 0
|
||||
m_WriteDefaultValues: 1
|
||||
m_Mirror: 0
|
||||
m_SpeedParameterActive: 0
|
||||
m_MirrorParameterActive: 0
|
||||
m_CycleOffsetParameterActive: 0
|
||||
m_TimeParameterActive: 0
|
||||
m_Motion: {fileID: 0}
|
||||
m_Tag:
|
||||
m_SpeedParameter:
|
||||
m_MirrorParameter:
|
||||
m_CycleOffsetParameter:
|
||||
m_TimeParameter:
|
8
BlueWater/Assets/07.Animation/Scout.controller.meta
Normal file
8
BlueWater/Assets/07.Animation/Scout.controller.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c637c3efa307b3641bde4945017354bb
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 9100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
651
BlueWater/Assets/07.Animation/SpearShieldman.controller
Normal file
651
BlueWater/Assets/07.Animation/SpearShieldman.controller
Normal file
@ -0,0 +1,651 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!206 &-9044354845508972843
|
||||
BlendTree:
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Blend Tree
|
||||
m_Childs:
|
||||
- serializedVersion: 2
|
||||
m_Motion: {fileID: 7400000, guid: 2da92735b7af1b6458b149b16df4af52, type: 3}
|
||||
m_Threshold: 0
|
||||
m_Position: {x: 0, y: 0}
|
||||
m_TimeScale: 1
|
||||
m_CycleOffset: 0
|
||||
m_DirectBlendParameter: Blend
|
||||
m_Mirror: 0
|
||||
- serializedVersion: 2
|
||||
m_Motion: {fileID: 7400000, guid: 0b62b3460f4dfd049a031d3352936537, type: 3}
|
||||
m_Threshold: 0.1
|
||||
m_Position: {x: 0, y: 0}
|
||||
m_TimeScale: 1
|
||||
m_CycleOffset: 0
|
||||
m_DirectBlendParameter: Blend
|
||||
m_Mirror: 0
|
||||
- serializedVersion: 2
|
||||
m_Motion: {fileID: 7400000, guid: b64e60e3fcbf21f4392f475291f62731, type: 3}
|
||||
m_Threshold: 1
|
||||
m_Position: {x: 0, y: 0}
|
||||
m_TimeScale: 1
|
||||
m_CycleOffset: 0
|
||||
m_DirectBlendParameter: Blend
|
||||
m_Mirror: 0
|
||||
m_BlendParameter: Speed
|
||||
m_BlendParameterY: Blend
|
||||
m_MinThreshold: 0
|
||||
m_MaxThreshold: 1
|
||||
m_UseAutomaticThresholds: 0
|
||||
m_NormalizedBlendValues: 0
|
||||
m_BlendType: 0
|
||||
--- !u!1102 &-8970947652927201876
|
||||
AnimatorState:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Idle
|
||||
m_Speed: 1
|
||||
m_CycleOffset: 0
|
||||
m_Transitions: []
|
||||
m_StateMachineBehaviours: []
|
||||
m_Position: {x: 50, y: 50, z: 0}
|
||||
m_IKOnFeet: 0
|
||||
m_WriteDefaultValues: 1
|
||||
m_Mirror: 0
|
||||
m_SpeedParameterActive: 0
|
||||
m_MirrorParameterActive: 0
|
||||
m_CycleOffsetParameterActive: 0
|
||||
m_TimeParameterActive: 0
|
||||
m_Motion: {fileID: 0}
|
||||
m_Tag:
|
||||
m_SpeedParameter:
|
||||
m_MirrorParameter:
|
||||
m_CycleOffsetParameter:
|
||||
m_TimeParameter:
|
||||
--- !u!1101 &-7854804674546960086
|
||||
AnimatorStateTransition:
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name:
|
||||
m_Conditions: []
|
||||
m_DstStateMachine: {fileID: 0}
|
||||
m_DstState: {fileID: 5304119996036113566}
|
||||
m_Solo: 0
|
||||
m_Mute: 0
|
||||
m_IsExit: 0
|
||||
serializedVersion: 3
|
||||
m_TransitionDuration: 0.25
|
||||
m_TransitionOffset: 0
|
||||
m_ExitTime: 0.625
|
||||
m_HasExitTime: 1
|
||||
m_HasFixedDuration: 1
|
||||
m_InterruptionSource: 0
|
||||
m_OrderedInterruption: 1
|
||||
m_CanTransitionToSelf: 1
|
||||
--- !u!1101 &-7488432702046877422
|
||||
AnimatorStateTransition:
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name:
|
||||
m_Conditions:
|
||||
- m_ConditionMode: 1
|
||||
m_ConditionEvent: TakeDamage
|
||||
m_EventTreshold: 0
|
||||
m_DstStateMachine: {fileID: 0}
|
||||
m_DstState: {fileID: -4719989283223396458}
|
||||
m_Solo: 0
|
||||
m_Mute: 0
|
||||
m_IsExit: 0
|
||||
serializedVersion: 3
|
||||
m_TransitionDuration: 0
|
||||
m_TransitionOffset: 0
|
||||
m_ExitTime: 0
|
||||
m_HasExitTime: 0
|
||||
m_HasFixedDuration: 1
|
||||
m_InterruptionSource: 0
|
||||
m_OrderedInterruption: 1
|
||||
m_CanTransitionToSelf: 1
|
||||
--- !u!1102 &-6677449554117134834
|
||||
AnimatorState:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: spearshield_06_death_B
|
||||
m_Speed: 1
|
||||
m_CycleOffset: 0
|
||||
m_Transitions: []
|
||||
m_StateMachineBehaviours: []
|
||||
m_Position: {x: 50, y: 50, z: 0}
|
||||
m_IKOnFeet: 0
|
||||
m_WriteDefaultValues: 1
|
||||
m_Mirror: 0
|
||||
m_SpeedParameterActive: 0
|
||||
m_MirrorParameterActive: 0
|
||||
m_CycleOffsetParameterActive: 0
|
||||
m_TimeParameterActive: 0
|
||||
m_Motion: {fileID: 7400000, guid: 91e2cd684a647a94e858c4d0aca6ba99, type: 3}
|
||||
m_Tag:
|
||||
m_SpeedParameter:
|
||||
m_MirrorParameter:
|
||||
m_CycleOffsetParameter:
|
||||
m_TimeParameter:
|
||||
--- !u!1102 &-5613045854842106462
|
||||
AnimatorState:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: spearshield_06_death_A
|
||||
m_Speed: 1
|
||||
m_CycleOffset: 0
|
||||
m_Transitions: []
|
||||
m_StateMachineBehaviours: []
|
||||
m_Position: {x: 50, y: 50, z: 0}
|
||||
m_IKOnFeet: 0
|
||||
m_WriteDefaultValues: 1
|
||||
m_Mirror: 0
|
||||
m_SpeedParameterActive: 0
|
||||
m_MirrorParameterActive: 0
|
||||
m_CycleOffsetParameterActive: 0
|
||||
m_TimeParameterActive: 0
|
||||
m_Motion: {fileID: 7400000, guid: 02ad53d9e50364848a06006f277b4a4b, type: 3}
|
||||
m_Tag:
|
||||
m_SpeedParameter:
|
||||
m_MirrorParameter:
|
||||
m_CycleOffsetParameter:
|
||||
m_TimeParameter:
|
||||
--- !u!1102 &-4719989283223396458
|
||||
AnimatorState:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: spearshield_05_damage
|
||||
m_Speed: 1
|
||||
m_CycleOffset: 0
|
||||
m_Transitions:
|
||||
- {fileID: -2853217596722282320}
|
||||
m_StateMachineBehaviours: []
|
||||
m_Position: {x: 50, y: 50, z: 0}
|
||||
m_IKOnFeet: 0
|
||||
m_WriteDefaultValues: 1
|
||||
m_Mirror: 0
|
||||
m_SpeedParameterActive: 0
|
||||
m_MirrorParameterActive: 0
|
||||
m_CycleOffsetParameterActive: 0
|
||||
m_TimeParameterActive: 0
|
||||
m_Motion: {fileID: 7400000, guid: f15c56ba5b9eacd4fbbdd19b750cc76a, type: 3}
|
||||
m_Tag:
|
||||
m_SpeedParameter:
|
||||
m_MirrorParameter:
|
||||
m_CycleOffsetParameter:
|
||||
m_TimeParameter:
|
||||
--- !u!1101 &-4045398789960513325
|
||||
AnimatorStateTransition:
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name:
|
||||
m_Conditions:
|
||||
- m_ConditionMode: 6
|
||||
m_ConditionEvent: AttackType
|
||||
m_EventTreshold: 1
|
||||
m_DstStateMachine: {fileID: 0}
|
||||
m_DstState: {fileID: 7758239304624801405}
|
||||
m_Solo: 0
|
||||
m_Mute: 0
|
||||
m_IsExit: 0
|
||||
serializedVersion: 3
|
||||
m_TransitionDuration: 0.25
|
||||
m_TransitionOffset: 0
|
||||
m_ExitTime: 0.8333334
|
||||
m_HasExitTime: 1
|
||||
m_HasFixedDuration: 1
|
||||
m_InterruptionSource: 0
|
||||
m_OrderedInterruption: 1
|
||||
m_CanTransitionToSelf: 1
|
||||
--- !u!1102 &-3262334696151519221
|
||||
AnimatorState:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: spearshield_04_attack_B
|
||||
m_Speed: 1
|
||||
m_CycleOffset: 0
|
||||
m_Transitions:
|
||||
- {fileID: -4045398789960513325}
|
||||
m_StateMachineBehaviours: []
|
||||
m_Position: {x: 50, y: 50, z: 0}
|
||||
m_IKOnFeet: 0
|
||||
m_WriteDefaultValues: 1
|
||||
m_Mirror: 0
|
||||
m_SpeedParameterActive: 0
|
||||
m_MirrorParameterActive: 0
|
||||
m_CycleOffsetParameterActive: 0
|
||||
m_TimeParameterActive: 0
|
||||
m_Motion: {fileID: 7400000, guid: b9def7c6da9201647b1bd65c6cafe6a8, type: 3}
|
||||
m_Tag:
|
||||
m_SpeedParameter:
|
||||
m_MirrorParameter:
|
||||
m_CycleOffsetParameter:
|
||||
m_TimeParameter:
|
||||
--- !u!1101 &-2853217596722282320
|
||||
AnimatorStateTransition:
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name:
|
||||
m_Conditions: []
|
||||
m_DstStateMachine: {fileID: 0}
|
||||
m_DstState: {fileID: 7758239304624801405}
|
||||
m_Solo: 0
|
||||
m_Mute: 0
|
||||
m_IsExit: 0
|
||||
serializedVersion: 3
|
||||
m_TransitionDuration: 0.25
|
||||
m_TransitionOffset: 0
|
||||
m_ExitTime: 0.625
|
||||
m_HasExitTime: 1
|
||||
m_HasFixedDuration: 1
|
||||
m_InterruptionSource: 0
|
||||
m_OrderedInterruption: 1
|
||||
m_CanTransitionToSelf: 1
|
||||
--- !u!1102 &-1588768182804401634
|
||||
AnimatorState:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: spearshield_04_attack_A
|
||||
m_Speed: 1
|
||||
m_CycleOffset: 0
|
||||
m_Transitions:
|
||||
- {fileID: 3907710630580683776}
|
||||
m_StateMachineBehaviours: []
|
||||
m_Position: {x: 50, y: 50, z: 0}
|
||||
m_IKOnFeet: 0
|
||||
m_WriteDefaultValues: 1
|
||||
m_Mirror: 0
|
||||
m_SpeedParameterActive: 0
|
||||
m_MirrorParameterActive: 0
|
||||
m_CycleOffsetParameterActive: 0
|
||||
m_TimeParameterActive: 0
|
||||
m_Motion: {fileID: 7400000, guid: 1111ae1477d1e214c84401ea31ee3425, type: 3}
|
||||
m_Tag:
|
||||
m_SpeedParameter:
|
||||
m_MirrorParameter:
|
||||
m_CycleOffsetParameter:
|
||||
m_TimeParameter:
|
||||
--- !u!1101 &-675634058516030415
|
||||
AnimatorStateTransition:
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name:
|
||||
m_Conditions:
|
||||
- m_ConditionMode: 6
|
||||
m_ConditionEvent: DeathType
|
||||
m_EventTreshold: 1
|
||||
- m_ConditionMode: 1
|
||||
m_ConditionEvent: Death
|
||||
m_EventTreshold: 0
|
||||
m_DstStateMachine: {fileID: 0}
|
||||
m_DstState: {fileID: -6677449554117134834}
|
||||
m_Solo: 0
|
||||
m_Mute: 0
|
||||
m_IsExit: 0
|
||||
serializedVersion: 3
|
||||
m_TransitionDuration: 0
|
||||
m_TransitionOffset: 0
|
||||
m_ExitTime: 0
|
||||
m_HasExitTime: 0
|
||||
m_HasFixedDuration: 1
|
||||
m_InterruptionSource: 0
|
||||
m_OrderedInterruption: 1
|
||||
m_CanTransitionToSelf: 1
|
||||
--- !u!91 &9100000
|
||||
AnimatorController:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: SpearShieldman
|
||||
serializedVersion: 5
|
||||
m_AnimatorParameters:
|
||||
- m_Name: Speed
|
||||
m_Type: 1
|
||||
m_DefaultFloat: 0
|
||||
m_DefaultInt: 0
|
||||
m_DefaultBool: 0
|
||||
m_Controller: {fileID: 9100000}
|
||||
- m_Name: AttackType
|
||||
m_Type: 3
|
||||
m_DefaultFloat: 0
|
||||
m_DefaultInt: 0
|
||||
m_DefaultBool: 0
|
||||
m_Controller: {fileID: 9100000}
|
||||
- m_Name: DeathType
|
||||
m_Type: 3
|
||||
m_DefaultFloat: 0
|
||||
m_DefaultInt: 0
|
||||
m_DefaultBool: 0
|
||||
m_Controller: {fileID: 9100000}
|
||||
- m_Name: Attack
|
||||
m_Type: 9
|
||||
m_DefaultFloat: 0
|
||||
m_DefaultInt: 0
|
||||
m_DefaultBool: 0
|
||||
m_Controller: {fileID: 9100000}
|
||||
- m_Name: TakeDamage
|
||||
m_Type: 9
|
||||
m_DefaultFloat: 0
|
||||
m_DefaultInt: 0
|
||||
m_DefaultBool: 0
|
||||
m_Controller: {fileID: 9100000}
|
||||
- m_Name: Death
|
||||
m_Type: 9
|
||||
m_DefaultFloat: 0
|
||||
m_DefaultInt: 0
|
||||
m_DefaultBool: 0
|
||||
m_Controller: {fileID: 9100000}
|
||||
m_AnimatorLayers:
|
||||
- serializedVersion: 5
|
||||
m_Name: Base
|
||||
m_StateMachine: {fileID: 167278188283925338}
|
||||
m_Mask: {fileID: 0}
|
||||
m_Motions: []
|
||||
m_Behaviours: []
|
||||
m_BlendingMode: 0
|
||||
m_SyncedLayerIndex: -1
|
||||
m_DefaultWeight: 0
|
||||
m_IKPass: 0
|
||||
m_SyncedLayerAffectsTiming: 0
|
||||
m_Controller: {fileID: 9100000}
|
||||
- serializedVersion: 5
|
||||
m_Name: UpperBody
|
||||
m_StateMachine: {fileID: 1014360538280732316}
|
||||
m_Mask: {fileID: 31900000, guid: ad8fbe0bee0314f4b845e2f964358778, type: 2}
|
||||
m_Motions: []
|
||||
m_Behaviours: []
|
||||
m_BlendingMode: 0
|
||||
m_SyncedLayerIndex: -1
|
||||
m_DefaultWeight: 1
|
||||
m_IKPass: 0
|
||||
m_SyncedLayerAffectsTiming: 0
|
||||
m_Controller: {fileID: 9100000}
|
||||
- serializedVersion: 5
|
||||
m_Name: FullBody
|
||||
m_StateMachine: {fileID: 7414727892699424751}
|
||||
m_Mask: {fileID: 0}
|
||||
m_Motions: []
|
||||
m_Behaviours: []
|
||||
m_BlendingMode: 0
|
||||
m_SyncedLayerIndex: -1
|
||||
m_DefaultWeight: 1
|
||||
m_IKPass: 0
|
||||
m_SyncedLayerAffectsTiming: 0
|
||||
m_Controller: {fileID: 9100000}
|
||||
--- !u!1107 &167278188283925338
|
||||
AnimatorStateMachine:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Base
|
||||
m_ChildStates:
|
||||
- serializedVersion: 1
|
||||
m_State: {fileID: 5304119996036113566}
|
||||
m_Position: {x: 360, y: 110, z: 0}
|
||||
m_ChildStateMachines: []
|
||||
m_AnyStateTransitions: []
|
||||
m_EntryTransitions: []
|
||||
m_StateMachineTransitions: {}
|
||||
m_StateMachineBehaviours: []
|
||||
m_AnyStatePosition: {x: 170, y: -30, z: 0}
|
||||
m_EntryPosition: {x: 50, y: 120, z: 0}
|
||||
m_ExitPosition: {x: 610, y: -10, z: 0}
|
||||
m_ParentStateMachinePosition: {x: 800, y: 20, z: 0}
|
||||
m_DefaultState: {fileID: 5304119996036113566}
|
||||
--- !u!1101 &301483702199899037
|
||||
AnimatorStateTransition:
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name:
|
||||
m_Conditions:
|
||||
- m_ConditionMode: 6
|
||||
m_ConditionEvent: AttackType
|
||||
m_EventTreshold: 0
|
||||
- m_ConditionMode: 1
|
||||
m_ConditionEvent: Attack
|
||||
m_EventTreshold: 0
|
||||
m_DstStateMachine: {fileID: 0}
|
||||
m_DstState: {fileID: -1588768182804401634}
|
||||
m_Solo: 0
|
||||
m_Mute: 0
|
||||
m_IsExit: 0
|
||||
serializedVersion: 3
|
||||
m_TransitionDuration: 0
|
||||
m_TransitionOffset: 0
|
||||
m_ExitTime: 0
|
||||
m_HasExitTime: 0
|
||||
m_HasFixedDuration: 1
|
||||
m_InterruptionSource: 0
|
||||
m_OrderedInterruption: 1
|
||||
m_CanTransitionToSelf: 1
|
||||
--- !u!1107 &1014360538280732316
|
||||
AnimatorStateMachine:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: UpperBody
|
||||
m_ChildStates:
|
||||
- serializedVersion: 1
|
||||
m_State: {fileID: 7758239304624801405}
|
||||
m_Position: {x: 380, y: 120, z: 0}
|
||||
- serializedVersion: 1
|
||||
m_State: {fileID: -1588768182804401634}
|
||||
m_Position: {x: 260, y: 260, z: 0}
|
||||
- serializedVersion: 1
|
||||
m_State: {fileID: -3262334696151519221}
|
||||
m_Position: {x: 570, y: 260, z: 0}
|
||||
- serializedVersion: 1
|
||||
m_State: {fileID: -4719989283223396458}
|
||||
m_Position: {x: 310, y: 10, z: 0}
|
||||
m_ChildStateMachines: []
|
||||
m_AnyStateTransitions:
|
||||
- {fileID: -7488432702046877422}
|
||||
m_EntryTransitions: []
|
||||
m_StateMachineTransitions: {}
|
||||
m_StateMachineBehaviours: []
|
||||
m_AnyStatePosition: {x: 50, y: 20, z: 0}
|
||||
m_EntryPosition: {x: 50, y: 120, z: 0}
|
||||
m_ExitPosition: {x: 800, y: 120, z: 0}
|
||||
m_ParentStateMachinePosition: {x: 800, y: 20, z: 0}
|
||||
m_DefaultState: {fileID: 7758239304624801405}
|
||||
--- !u!1101 &3907710630580683776
|
||||
AnimatorStateTransition:
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name:
|
||||
m_Conditions:
|
||||
- m_ConditionMode: 6
|
||||
m_ConditionEvent: AttackType
|
||||
m_EventTreshold: 0
|
||||
m_DstStateMachine: {fileID: 0}
|
||||
m_DstState: {fileID: 7758239304624801405}
|
||||
m_Solo: 0
|
||||
m_Mute: 0
|
||||
m_IsExit: 0
|
||||
serializedVersion: 3
|
||||
m_TransitionDuration: 0.25
|
||||
m_TransitionOffset: 0
|
||||
m_ExitTime: 0.8333334
|
||||
m_HasExitTime: 1
|
||||
m_HasFixedDuration: 1
|
||||
m_InterruptionSource: 0
|
||||
m_OrderedInterruption: 1
|
||||
m_CanTransitionToSelf: 1
|
||||
--- !u!1102 &5304119996036113566
|
||||
AnimatorState:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Blend Tree
|
||||
m_Speed: 1
|
||||
m_CycleOffset: 0
|
||||
m_Transitions: []
|
||||
m_StateMachineBehaviours: []
|
||||
m_Position: {x: 50, y: 50, z: 0}
|
||||
m_IKOnFeet: 0
|
||||
m_WriteDefaultValues: 1
|
||||
m_Mirror: 0
|
||||
m_SpeedParameterActive: 0
|
||||
m_MirrorParameterActive: 0
|
||||
m_CycleOffsetParameterActive: 0
|
||||
m_TimeParameterActive: 0
|
||||
m_Motion: {fileID: -9044354845508972843}
|
||||
m_Tag:
|
||||
m_SpeedParameter:
|
||||
m_MirrorParameter:
|
||||
m_CycleOffsetParameter:
|
||||
m_TimeParameter:
|
||||
--- !u!1101 &5378458499681276728
|
||||
AnimatorStateTransition:
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name:
|
||||
m_Conditions:
|
||||
- m_ConditionMode: 6
|
||||
m_ConditionEvent: DeathType
|
||||
m_EventTreshold: 0
|
||||
- m_ConditionMode: 1
|
||||
m_ConditionEvent: Death
|
||||
m_EventTreshold: 0
|
||||
m_DstStateMachine: {fileID: 0}
|
||||
m_DstState: {fileID: -5613045854842106462}
|
||||
m_Solo: 0
|
||||
m_Mute: 0
|
||||
m_IsExit: 0
|
||||
serializedVersion: 3
|
||||
m_TransitionDuration: 0
|
||||
m_TransitionOffset: 0
|
||||
m_ExitTime: 0
|
||||
m_HasExitTime: 0
|
||||
m_HasFixedDuration: 1
|
||||
m_InterruptionSource: 0
|
||||
m_OrderedInterruption: 1
|
||||
m_CanTransitionToSelf: 1
|
||||
--- !u!1101 &7243255047482691604
|
||||
AnimatorStateTransition:
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name:
|
||||
m_Conditions:
|
||||
- m_ConditionMode: 6
|
||||
m_ConditionEvent: AttackType
|
||||
m_EventTreshold: 1
|
||||
- m_ConditionMode: 1
|
||||
m_ConditionEvent: Attack
|
||||
m_EventTreshold: 0
|
||||
m_DstStateMachine: {fileID: 0}
|
||||
m_DstState: {fileID: -3262334696151519221}
|
||||
m_Solo: 0
|
||||
m_Mute: 0
|
||||
m_IsExit: 0
|
||||
serializedVersion: 3
|
||||
m_TransitionDuration: 0
|
||||
m_TransitionOffset: 0
|
||||
m_ExitTime: 0
|
||||
m_HasExitTime: 0
|
||||
m_HasFixedDuration: 1
|
||||
m_InterruptionSource: 0
|
||||
m_OrderedInterruption: 1
|
||||
m_CanTransitionToSelf: 1
|
||||
--- !u!1107 &7414727892699424751
|
||||
AnimatorStateMachine:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: FullBody
|
||||
m_ChildStates:
|
||||
- serializedVersion: 1
|
||||
m_State: {fileID: -6677449554117134834}
|
||||
m_Position: {x: 360, y: 20, z: 0}
|
||||
- serializedVersion: 1
|
||||
m_State: {fileID: -5613045854842106462}
|
||||
m_Position: {x: 360, y: -30, z: 0}
|
||||
- serializedVersion: 1
|
||||
m_State: {fileID: -8970947652927201876}
|
||||
m_Position: {x: 400, y: 140, z: 0}
|
||||
m_ChildStateMachines: []
|
||||
m_AnyStateTransitions:
|
||||
- {fileID: 5378458499681276728}
|
||||
- {fileID: -675634058516030415}
|
||||
m_EntryTransitions: []
|
||||
m_StateMachineTransitions: {}
|
||||
m_StateMachineBehaviours: []
|
||||
m_AnyStatePosition: {x: 50, y: 20, z: 0}
|
||||
m_EntryPosition: {x: 60, y: 140, z: 0}
|
||||
m_ExitPosition: {x: 800, y: 120, z: 0}
|
||||
m_ParentStateMachinePosition: {x: 800, y: 20, z: 0}
|
||||
m_DefaultState: {fileID: -8970947652927201876}
|
||||
--- !u!1102 &7758239304624801405
|
||||
AnimatorState:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Idle
|
||||
m_Speed: 1
|
||||
m_CycleOffset: 0
|
||||
m_Transitions:
|
||||
- {fileID: 301483702199899037}
|
||||
- {fileID: 7243255047482691604}
|
||||
m_StateMachineBehaviours: []
|
||||
m_Position: {x: 50, y: 50, z: 0}
|
||||
m_IKOnFeet: 0
|
||||
m_WriteDefaultValues: 1
|
||||
m_Mirror: 0
|
||||
m_SpeedParameterActive: 0
|
||||
m_MirrorParameterActive: 0
|
||||
m_CycleOffsetParameterActive: 0
|
||||
m_TimeParameterActive: 0
|
||||
m_Motion: {fileID: 0}
|
||||
m_Tag:
|
||||
m_SpeedParameter:
|
||||
m_MirrorParameter:
|
||||
m_CycleOffsetParameter:
|
||||
m_TimeParameter:
|
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cb7d7f4379987ac47b445f6074dbbdf2
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 9100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
651
BlueWater/Assets/07.Animation/Spearman.controller
Normal file
651
BlueWater/Assets/07.Animation/Spearman.controller
Normal file
@ -0,0 +1,651 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!206 &-9044354845508972843
|
||||
BlendTree:
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Blend Tree
|
||||
m_Childs:
|
||||
- serializedVersion: 2
|
||||
m_Motion: {fileID: 7400000, guid: b77a0151c1c2b6842a830f5bc60644c4, type: 3}
|
||||
m_Threshold: 0
|
||||
m_Position: {x: 0, y: 0}
|
||||
m_TimeScale: 1
|
||||
m_CycleOffset: 0
|
||||
m_DirectBlendParameter: Blend
|
||||
m_Mirror: 0
|
||||
- serializedVersion: 2
|
||||
m_Motion: {fileID: 7400000, guid: e9ff7855f8770f148b154b61073963fb, type: 3}
|
||||
m_Threshold: 0.1
|
||||
m_Position: {x: 0, y: 0}
|
||||
m_TimeScale: 1
|
||||
m_CycleOffset: 0
|
||||
m_DirectBlendParameter: Blend
|
||||
m_Mirror: 0
|
||||
- serializedVersion: 2
|
||||
m_Motion: {fileID: 7400000, guid: 90db24b13a227fd46a43bb6cf2c5f729, type: 3}
|
||||
m_Threshold: 1
|
||||
m_Position: {x: 0, y: 0}
|
||||
m_TimeScale: 1
|
||||
m_CycleOffset: 0
|
||||
m_DirectBlendParameter: Blend
|
||||
m_Mirror: 0
|
||||
m_BlendParameter: Speed
|
||||
m_BlendParameterY: Blend
|
||||
m_MinThreshold: 0
|
||||
m_MaxThreshold: 1
|
||||
m_UseAutomaticThresholds: 0
|
||||
m_NormalizedBlendValues: 0
|
||||
m_BlendType: 0
|
||||
--- !u!1102 &-8970947652927201876
|
||||
AnimatorState:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Idle
|
||||
m_Speed: 1
|
||||
m_CycleOffset: 0
|
||||
m_Transitions: []
|
||||
m_StateMachineBehaviours: []
|
||||
m_Position: {x: 50, y: 50, z: 0}
|
||||
m_IKOnFeet: 0
|
||||
m_WriteDefaultValues: 1
|
||||
m_Mirror: 0
|
||||
m_SpeedParameterActive: 0
|
||||
m_MirrorParameterActive: 0
|
||||
m_CycleOffsetParameterActive: 0
|
||||
m_TimeParameterActive: 0
|
||||
m_Motion: {fileID: 0}
|
||||
m_Tag:
|
||||
m_SpeedParameter:
|
||||
m_MirrorParameter:
|
||||
m_CycleOffsetParameter:
|
||||
m_TimeParameter:
|
||||
--- !u!1101 &-7854804674546960086
|
||||
AnimatorStateTransition:
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name:
|
||||
m_Conditions: []
|
||||
m_DstStateMachine: {fileID: 0}
|
||||
m_DstState: {fileID: 5304119996036113566}
|
||||
m_Solo: 0
|
||||
m_Mute: 0
|
||||
m_IsExit: 0
|
||||
serializedVersion: 3
|
||||
m_TransitionDuration: 0.25
|
||||
m_TransitionOffset: 0
|
||||
m_ExitTime: 0.625
|
||||
m_HasExitTime: 1
|
||||
m_HasFixedDuration: 1
|
||||
m_InterruptionSource: 0
|
||||
m_OrderedInterruption: 1
|
||||
m_CanTransitionToSelf: 1
|
||||
--- !u!1101 &-7488432702046877422
|
||||
AnimatorStateTransition:
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name:
|
||||
m_Conditions:
|
||||
- m_ConditionMode: 1
|
||||
m_ConditionEvent: TakeDamage
|
||||
m_EventTreshold: 0
|
||||
m_DstStateMachine: {fileID: 0}
|
||||
m_DstState: {fileID: -4719989283223396458}
|
||||
m_Solo: 0
|
||||
m_Mute: 0
|
||||
m_IsExit: 0
|
||||
serializedVersion: 3
|
||||
m_TransitionDuration: 0
|
||||
m_TransitionOffset: 0
|
||||
m_ExitTime: 0
|
||||
m_HasExitTime: 0
|
||||
m_HasFixedDuration: 1
|
||||
m_InterruptionSource: 0
|
||||
m_OrderedInterruption: 1
|
||||
m_CanTransitionToSelf: 1
|
||||
--- !u!1102 &-6677449554117134834
|
||||
AnimatorState:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: spear_06_death_B
|
||||
m_Speed: 1
|
||||
m_CycleOffset: 0
|
||||
m_Transitions: []
|
||||
m_StateMachineBehaviours: []
|
||||
m_Position: {x: 50, y: 50, z: 0}
|
||||
m_IKOnFeet: 0
|
||||
m_WriteDefaultValues: 1
|
||||
m_Mirror: 0
|
||||
m_SpeedParameterActive: 0
|
||||
m_MirrorParameterActive: 0
|
||||
m_CycleOffsetParameterActive: 0
|
||||
m_TimeParameterActive: 0
|
||||
m_Motion: {fileID: 7400000, guid: 505b2fbca113d954c9b18b1a2e55a117, type: 3}
|
||||
m_Tag:
|
||||
m_SpeedParameter:
|
||||
m_MirrorParameter:
|
||||
m_CycleOffsetParameter:
|
||||
m_TimeParameter:
|
||||
--- !u!1102 &-5613045854842106462
|
||||
AnimatorState:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: spear_06_death_A
|
||||
m_Speed: 1
|
||||
m_CycleOffset: 0
|
||||
m_Transitions: []
|
||||
m_StateMachineBehaviours: []
|
||||
m_Position: {x: 50, y: 50, z: 0}
|
||||
m_IKOnFeet: 0
|
||||
m_WriteDefaultValues: 1
|
||||
m_Mirror: 0
|
||||
m_SpeedParameterActive: 0
|
||||
m_MirrorParameterActive: 0
|
||||
m_CycleOffsetParameterActive: 0
|
||||
m_TimeParameterActive: 0
|
||||
m_Motion: {fileID: 7400000, guid: e345dfb73b1572d43b93fbda56b53815, type: 3}
|
||||
m_Tag:
|
||||
m_SpeedParameter:
|
||||
m_MirrorParameter:
|
||||
m_CycleOffsetParameter:
|
||||
m_TimeParameter:
|
||||
--- !u!1102 &-4719989283223396458
|
||||
AnimatorState:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: spear_05_damage
|
||||
m_Speed: 1
|
||||
m_CycleOffset: 0
|
||||
m_Transitions:
|
||||
- {fileID: -2853217596722282320}
|
||||
m_StateMachineBehaviours: []
|
||||
m_Position: {x: 50, y: 50, z: 0}
|
||||
m_IKOnFeet: 0
|
||||
m_WriteDefaultValues: 1
|
||||
m_Mirror: 0
|
||||
m_SpeedParameterActive: 0
|
||||
m_MirrorParameterActive: 0
|
||||
m_CycleOffsetParameterActive: 0
|
||||
m_TimeParameterActive: 0
|
||||
m_Motion: {fileID: 7400000, guid: 628afcd6c2726c8438d41426e1658ede, type: 3}
|
||||
m_Tag:
|
||||
m_SpeedParameter:
|
||||
m_MirrorParameter:
|
||||
m_CycleOffsetParameter:
|
||||
m_TimeParameter:
|
||||
--- !u!1101 &-4045398789960513325
|
||||
AnimatorStateTransition:
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name:
|
||||
m_Conditions:
|
||||
- m_ConditionMode: 6
|
||||
m_ConditionEvent: AttackType
|
||||
m_EventTreshold: 1
|
||||
m_DstStateMachine: {fileID: 0}
|
||||
m_DstState: {fileID: 7758239304624801405}
|
||||
m_Solo: 0
|
||||
m_Mute: 0
|
||||
m_IsExit: 0
|
||||
serializedVersion: 3
|
||||
m_TransitionDuration: 0.25
|
||||
m_TransitionOffset: 0
|
||||
m_ExitTime: 0.8333334
|
||||
m_HasExitTime: 1
|
||||
m_HasFixedDuration: 1
|
||||
m_InterruptionSource: 0
|
||||
m_OrderedInterruption: 1
|
||||
m_CanTransitionToSelf: 1
|
||||
--- !u!1102 &-3262334696151519221
|
||||
AnimatorState:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: spear_04_attack_B
|
||||
m_Speed: 1
|
||||
m_CycleOffset: 0
|
||||
m_Transitions:
|
||||
- {fileID: -4045398789960513325}
|
||||
m_StateMachineBehaviours: []
|
||||
m_Position: {x: 50, y: 50, z: 0}
|
||||
m_IKOnFeet: 0
|
||||
m_WriteDefaultValues: 1
|
||||
m_Mirror: 0
|
||||
m_SpeedParameterActive: 0
|
||||
m_MirrorParameterActive: 0
|
||||
m_CycleOffsetParameterActive: 0
|
||||
m_TimeParameterActive: 0
|
||||
m_Motion: {fileID: 7400000, guid: dabce5525f41e3b43b71afba5951f91a, type: 3}
|
||||
m_Tag:
|
||||
m_SpeedParameter:
|
||||
m_MirrorParameter:
|
||||
m_CycleOffsetParameter:
|
||||
m_TimeParameter:
|
||||
--- !u!1101 &-2853217596722282320
|
||||
AnimatorStateTransition:
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name:
|
||||
m_Conditions: []
|
||||
m_DstStateMachine: {fileID: 0}
|
||||
m_DstState: {fileID: 7758239304624801405}
|
||||
m_Solo: 0
|
||||
m_Mute: 0
|
||||
m_IsExit: 0
|
||||
serializedVersion: 3
|
||||
m_TransitionDuration: 0.25
|
||||
m_TransitionOffset: 0
|
||||
m_ExitTime: 0.625
|
||||
m_HasExitTime: 1
|
||||
m_HasFixedDuration: 1
|
||||
m_InterruptionSource: 0
|
||||
m_OrderedInterruption: 1
|
||||
m_CanTransitionToSelf: 1
|
||||
--- !u!1102 &-1588768182804401634
|
||||
AnimatorState:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: spear_04_attack_A
|
||||
m_Speed: 1
|
||||
m_CycleOffset: 0
|
||||
m_Transitions:
|
||||
- {fileID: 3907710630580683776}
|
||||
m_StateMachineBehaviours: []
|
||||
m_Position: {x: 50, y: 50, z: 0}
|
||||
m_IKOnFeet: 0
|
||||
m_WriteDefaultValues: 1
|
||||
m_Mirror: 0
|
||||
m_SpeedParameterActive: 0
|
||||
m_MirrorParameterActive: 0
|
||||
m_CycleOffsetParameterActive: 0
|
||||
m_TimeParameterActive: 0
|
||||
m_Motion: {fileID: 7400000, guid: 7ae56d5469e7f334abb22dd37f302bd6, type: 3}
|
||||
m_Tag:
|
||||
m_SpeedParameter:
|
||||
m_MirrorParameter:
|
||||
m_CycleOffsetParameter:
|
||||
m_TimeParameter:
|
||||
--- !u!1101 &-675634058516030415
|
||||
AnimatorStateTransition:
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name:
|
||||
m_Conditions:
|
||||
- m_ConditionMode: 6
|
||||
m_ConditionEvent: DeathType
|
||||
m_EventTreshold: 1
|
||||
- m_ConditionMode: 1
|
||||
m_ConditionEvent: Death
|
||||
m_EventTreshold: 0
|
||||
m_DstStateMachine: {fileID: 0}
|
||||
m_DstState: {fileID: -6677449554117134834}
|
||||
m_Solo: 0
|
||||
m_Mute: 0
|
||||
m_IsExit: 0
|
||||
serializedVersion: 3
|
||||
m_TransitionDuration: 0
|
||||
m_TransitionOffset: 0
|
||||
m_ExitTime: 0
|
||||
m_HasExitTime: 0
|
||||
m_HasFixedDuration: 1
|
||||
m_InterruptionSource: 0
|
||||
m_OrderedInterruption: 1
|
||||
m_CanTransitionToSelf: 1
|
||||
--- !u!91 &9100000
|
||||
AnimatorController:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Spearman
|
||||
serializedVersion: 5
|
||||
m_AnimatorParameters:
|
||||
- m_Name: Speed
|
||||
m_Type: 1
|
||||
m_DefaultFloat: 0
|
||||
m_DefaultInt: 0
|
||||
m_DefaultBool: 0
|
||||
m_Controller: {fileID: 9100000}
|
||||
- m_Name: AttackType
|
||||
m_Type: 3
|
||||
m_DefaultFloat: 0
|
||||
m_DefaultInt: 0
|
||||
m_DefaultBool: 0
|
||||
m_Controller: {fileID: 9100000}
|
||||
- m_Name: DeathType
|
||||
m_Type: 3
|
||||
m_DefaultFloat: 0
|
||||
m_DefaultInt: 0
|
||||
m_DefaultBool: 0
|
||||
m_Controller: {fileID: 9100000}
|
||||
- m_Name: Attack
|
||||
m_Type: 9
|
||||
m_DefaultFloat: 0
|
||||
m_DefaultInt: 0
|
||||
m_DefaultBool: 0
|
||||
m_Controller: {fileID: 9100000}
|
||||
- m_Name: TakeDamage
|
||||
m_Type: 9
|
||||
m_DefaultFloat: 0
|
||||
m_DefaultInt: 0
|
||||
m_DefaultBool: 0
|
||||
m_Controller: {fileID: 9100000}
|
||||
- m_Name: Death
|
||||
m_Type: 9
|
||||
m_DefaultFloat: 0
|
||||
m_DefaultInt: 0
|
||||
m_DefaultBool: 0
|
||||
m_Controller: {fileID: 9100000}
|
||||
m_AnimatorLayers:
|
||||
- serializedVersion: 5
|
||||
m_Name: Base
|
||||
m_StateMachine: {fileID: 167278188283925338}
|
||||
m_Mask: {fileID: 0}
|
||||
m_Motions: []
|
||||
m_Behaviours: []
|
||||
m_BlendingMode: 0
|
||||
m_SyncedLayerIndex: -1
|
||||
m_DefaultWeight: 0
|
||||
m_IKPass: 0
|
||||
m_SyncedLayerAffectsTiming: 0
|
||||
m_Controller: {fileID: 9100000}
|
||||
- serializedVersion: 5
|
||||
m_Name: UpperBody
|
||||
m_StateMachine: {fileID: 1014360538280732316}
|
||||
m_Mask: {fileID: 31900000, guid: ad8fbe0bee0314f4b845e2f964358778, type: 2}
|
||||
m_Motions: []
|
||||
m_Behaviours: []
|
||||
m_BlendingMode: 0
|
||||
m_SyncedLayerIndex: -1
|
||||
m_DefaultWeight: 1
|
||||
m_IKPass: 0
|
||||
m_SyncedLayerAffectsTiming: 0
|
||||
m_Controller: {fileID: 9100000}
|
||||
- serializedVersion: 5
|
||||
m_Name: FullBody
|
||||
m_StateMachine: {fileID: 7414727892699424751}
|
||||
m_Mask: {fileID: 0}
|
||||
m_Motions: []
|
||||
m_Behaviours: []
|
||||
m_BlendingMode: 0
|
||||
m_SyncedLayerIndex: -1
|
||||
m_DefaultWeight: 1
|
||||
m_IKPass: 0
|
||||
m_SyncedLayerAffectsTiming: 0
|
||||
m_Controller: {fileID: 9100000}
|
||||
--- !u!1107 &167278188283925338
|
||||
AnimatorStateMachine:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Base
|
||||
m_ChildStates:
|
||||
- serializedVersion: 1
|
||||
m_State: {fileID: 5304119996036113566}
|
||||
m_Position: {x: 360, y: 110, z: 0}
|
||||
m_ChildStateMachines: []
|
||||
m_AnyStateTransitions: []
|
||||
m_EntryTransitions: []
|
||||
m_StateMachineTransitions: {}
|
||||
m_StateMachineBehaviours: []
|
||||
m_AnyStatePosition: {x: 170, y: -30, z: 0}
|
||||
m_EntryPosition: {x: 50, y: 120, z: 0}
|
||||
m_ExitPosition: {x: 610, y: -10, z: 0}
|
||||
m_ParentStateMachinePosition: {x: 800, y: 20, z: 0}
|
||||
m_DefaultState: {fileID: 5304119996036113566}
|
||||
--- !u!1101 &301483702199899037
|
||||
AnimatorStateTransition:
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name:
|
||||
m_Conditions:
|
||||
- m_ConditionMode: 6
|
||||
m_ConditionEvent: AttackType
|
||||
m_EventTreshold: 0
|
||||
- m_ConditionMode: 1
|
||||
m_ConditionEvent: Attack
|
||||
m_EventTreshold: 0
|
||||
m_DstStateMachine: {fileID: 0}
|
||||
m_DstState: {fileID: -1588768182804401634}
|
||||
m_Solo: 0
|
||||
m_Mute: 0
|
||||
m_IsExit: 0
|
||||
serializedVersion: 3
|
||||
m_TransitionDuration: 0
|
||||
m_TransitionOffset: 0
|
||||
m_ExitTime: 0
|
||||
m_HasExitTime: 0
|
||||
m_HasFixedDuration: 1
|
||||
m_InterruptionSource: 0
|
||||
m_OrderedInterruption: 1
|
||||
m_CanTransitionToSelf: 1
|
||||
--- !u!1107 &1014360538280732316
|
||||
AnimatorStateMachine:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: UpperBody
|
||||
m_ChildStates:
|
||||
- serializedVersion: 1
|
||||
m_State: {fileID: 7758239304624801405}
|
||||
m_Position: {x: 380, y: 120, z: 0}
|
||||
- serializedVersion: 1
|
||||
m_State: {fileID: -1588768182804401634}
|
||||
m_Position: {x: 260, y: 260, z: 0}
|
||||
- serializedVersion: 1
|
||||
m_State: {fileID: -3262334696151519221}
|
||||
m_Position: {x: 570, y: 260, z: 0}
|
||||
- serializedVersion: 1
|
||||
m_State: {fileID: -4719989283223396458}
|
||||
m_Position: {x: 310, y: 10, z: 0}
|
||||
m_ChildStateMachines: []
|
||||
m_AnyStateTransitions:
|
||||
- {fileID: -7488432702046877422}
|
||||
m_EntryTransitions: []
|
||||
m_StateMachineTransitions: {}
|
||||
m_StateMachineBehaviours: []
|
||||
m_AnyStatePosition: {x: 50, y: 20, z: 0}
|
||||
m_EntryPosition: {x: 50, y: 120, z: 0}
|
||||
m_ExitPosition: {x: 800, y: 120, z: 0}
|
||||
m_ParentStateMachinePosition: {x: 800, y: 20, z: 0}
|
||||
m_DefaultState: {fileID: 7758239304624801405}
|
||||
--- !u!1101 &3907710630580683776
|
||||
AnimatorStateTransition:
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name:
|
||||
m_Conditions:
|
||||
- m_ConditionMode: 6
|
||||
m_ConditionEvent: AttackType
|
||||
m_EventTreshold: 0
|
||||
m_DstStateMachine: {fileID: 0}
|
||||
m_DstState: {fileID: 7758239304624801405}
|
||||
m_Solo: 0
|
||||
m_Mute: 0
|
||||
m_IsExit: 0
|
||||
serializedVersion: 3
|
||||
m_TransitionDuration: 0.25
|
||||
m_TransitionOffset: 0
|
||||
m_ExitTime: 0.8333334
|
||||
m_HasExitTime: 1
|
||||
m_HasFixedDuration: 1
|
||||
m_InterruptionSource: 0
|
||||
m_OrderedInterruption: 1
|
||||
m_CanTransitionToSelf: 1
|
||||
--- !u!1102 &5304119996036113566
|
||||
AnimatorState:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Blend Tree
|
||||
m_Speed: 1
|
||||
m_CycleOffset: 0
|
||||
m_Transitions: []
|
||||
m_StateMachineBehaviours: []
|
||||
m_Position: {x: 50, y: 50, z: 0}
|
||||
m_IKOnFeet: 0
|
||||
m_WriteDefaultValues: 1
|
||||
m_Mirror: 0
|
||||
m_SpeedParameterActive: 0
|
||||
m_MirrorParameterActive: 0
|
||||
m_CycleOffsetParameterActive: 0
|
||||
m_TimeParameterActive: 0
|
||||
m_Motion: {fileID: -9044354845508972843}
|
||||
m_Tag:
|
||||
m_SpeedParameter:
|
||||
m_MirrorParameter:
|
||||
m_CycleOffsetParameter:
|
||||
m_TimeParameter:
|
||||
--- !u!1101 &5378458499681276728
|
||||
AnimatorStateTransition:
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name:
|
||||
m_Conditions:
|
||||
- m_ConditionMode: 6
|
||||
m_ConditionEvent: DeathType
|
||||
m_EventTreshold: 0
|
||||
- m_ConditionMode: 1
|
||||
m_ConditionEvent: Death
|
||||
m_EventTreshold: 0
|
||||
m_DstStateMachine: {fileID: 0}
|
||||
m_DstState: {fileID: -5613045854842106462}
|
||||
m_Solo: 0
|
||||
m_Mute: 0
|
||||
m_IsExit: 0
|
||||
serializedVersion: 3
|
||||
m_TransitionDuration: 0
|
||||
m_TransitionOffset: 0
|
||||
m_ExitTime: 0
|
||||
m_HasExitTime: 0
|
||||
m_HasFixedDuration: 1
|
||||
m_InterruptionSource: 0
|
||||
m_OrderedInterruption: 1
|
||||
m_CanTransitionToSelf: 1
|
||||
--- !u!1101 &7243255047482691604
|
||||
AnimatorStateTransition:
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name:
|
||||
m_Conditions:
|
||||
- m_ConditionMode: 6
|
||||
m_ConditionEvent: AttackType
|
||||
m_EventTreshold: 1
|
||||
- m_ConditionMode: 1
|
||||
m_ConditionEvent: Attack
|
||||
m_EventTreshold: 0
|
||||
m_DstStateMachine: {fileID: 0}
|
||||
m_DstState: {fileID: -3262334696151519221}
|
||||
m_Solo: 0
|
||||
m_Mute: 0
|
||||
m_IsExit: 0
|
||||
serializedVersion: 3
|
||||
m_TransitionDuration: 0
|
||||
m_TransitionOffset: 0
|
||||
m_ExitTime: 0
|
||||
m_HasExitTime: 0
|
||||
m_HasFixedDuration: 1
|
||||
m_InterruptionSource: 0
|
||||
m_OrderedInterruption: 1
|
||||
m_CanTransitionToSelf: 1
|
||||
--- !u!1107 &7414727892699424751
|
||||
AnimatorStateMachine:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: FullBody
|
||||
m_ChildStates:
|
||||
- serializedVersion: 1
|
||||
m_State: {fileID: -6677449554117134834}
|
||||
m_Position: {x: 360, y: 20, z: 0}
|
||||
- serializedVersion: 1
|
||||
m_State: {fileID: -5613045854842106462}
|
||||
m_Position: {x: 360, y: -30, z: 0}
|
||||
- serializedVersion: 1
|
||||
m_State: {fileID: -8970947652927201876}
|
||||
m_Position: {x: 400, y: 140, z: 0}
|
||||
m_ChildStateMachines: []
|
||||
m_AnyStateTransitions:
|
||||
- {fileID: 5378458499681276728}
|
||||
- {fileID: -675634058516030415}
|
||||
m_EntryTransitions: []
|
||||
m_StateMachineTransitions: {}
|
||||
m_StateMachineBehaviours: []
|
||||
m_AnyStatePosition: {x: 50, y: 20, z: 0}
|
||||
m_EntryPosition: {x: 60, y: 140, z: 0}
|
||||
m_ExitPosition: {x: 800, y: 120, z: 0}
|
||||
m_ParentStateMachinePosition: {x: 800, y: 20, z: 0}
|
||||
m_DefaultState: {fileID: -8970947652927201876}
|
||||
--- !u!1102 &7758239304624801405
|
||||
AnimatorState:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Idle
|
||||
m_Speed: 1
|
||||
m_CycleOffset: 0
|
||||
m_Transitions:
|
||||
- {fileID: 301483702199899037}
|
||||
- {fileID: 7243255047482691604}
|
||||
m_StateMachineBehaviours: []
|
||||
m_Position: {x: 50, y: 50, z: 0}
|
||||
m_IKOnFeet: 0
|
||||
m_WriteDefaultValues: 1
|
||||
m_Mirror: 0
|
||||
m_SpeedParameterActive: 0
|
||||
m_MirrorParameterActive: 0
|
||||
m_CycleOffsetParameterActive: 0
|
||||
m_TimeParameterActive: 0
|
||||
m_Motion: {fileID: 0}
|
||||
m_Tag:
|
||||
m_SpeedParameter:
|
||||
m_MirrorParameter:
|
||||
m_CycleOffsetParameter:
|
||||
m_TimeParameter:
|
8
BlueWater/Assets/07.Animation/Spearman.controller.meta
Normal file
8
BlueWater/Assets/07.Animation/Spearman.controller.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9f0a9572ffcdefc49b34f61fb0a0f801
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 9100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
BlueWater/Assets/AddressableAssetsData.meta
Normal file
8
BlueWater/Assets/AddressableAssetsData.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 41e2ee40285c0402d8c2f912ce2b5bd3
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,109 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 468a46d0ae32c3544b7d98094e6448a9, type: 3}
|
||||
m_Name: AddressableAssetSettings
|
||||
m_EditorClassIdentifier:
|
||||
m_DefaultGroup: 84c68c72d64fe49b4a85c32c0eaeab8b
|
||||
m_currentHash:
|
||||
serializedVersion: 2
|
||||
Hash: 00000000000000000000000000000000
|
||||
m_OptimizeCatalogSize: 0
|
||||
m_BuildRemoteCatalog: 0
|
||||
m_BundleLocalCatalog: 0
|
||||
m_CatalogRequestsTimeout: 0
|
||||
m_DisableCatalogUpdateOnStart: 0
|
||||
m_IgnoreUnsupportedFilesInBuild: 0
|
||||
m_UniqueBundleIds: 0
|
||||
m_NonRecursiveBuilding: 1
|
||||
m_CCDEnabled: 0
|
||||
m_maxConcurrentWebRequests: 3
|
||||
m_ContiguousBundles: 1
|
||||
m_StripUnityVersionFromBundleBuild: 0
|
||||
m_DisableVisibleSubAssetRepresentations: 0
|
||||
m_ShaderBundleNaming: 0
|
||||
m_ShaderBundleCustomNaming:
|
||||
m_MonoScriptBundleNaming: 0
|
||||
m_CheckForContentUpdateRestrictionsOption: 0
|
||||
m_MonoScriptBundleCustomNaming:
|
||||
m_RemoteCatalogBuildPath:
|
||||
m_Id:
|
||||
m_RemoteCatalogLoadPath:
|
||||
m_Id:
|
||||
m_ContentStateBuildPathProfileVariableName:
|
||||
m_CustomContentStateBuildPath:
|
||||
m_ContentStateBuildPath:
|
||||
m_BuildAddressablesWithPlayerBuild: 0
|
||||
m_overridePlayerVersion: '[UnityEditor.PlayerSettings.bundleVersion]'
|
||||
m_GroupAssets:
|
||||
- {fileID: 11400000, guid: 2c37f0ef7084841f296bbd0e51caeaad, type: 2}
|
||||
- {fileID: 11400000, guid: 923dc60ba1f704952b558228228d4e8b, type: 2}
|
||||
m_BuildSettings:
|
||||
m_CompileScriptsInVirtualMode: 0
|
||||
m_CleanupStreamingAssetsAfterBuilds: 1
|
||||
m_LogResourceManagerExceptions: 1
|
||||
m_BundleBuildPath: Temp/com.unity.addressables/AssetBundles
|
||||
m_ProfileSettings:
|
||||
m_Profiles:
|
||||
- m_InheritedParent:
|
||||
m_Id: 803cb393e1ba44d13b8a99db308b84af
|
||||
m_ProfileName: Default
|
||||
m_Values:
|
||||
- m_Id: f976e802859f042bcbf93445e0074b55
|
||||
m_Value: '[UnityEditor.EditorUserBuildSettings.activeBuildTarget]'
|
||||
- m_Id: 1f7171e531b2e45589a60a1df6e16b4b
|
||||
m_Value: '[UnityEngine.AddressableAssets.Addressables.BuildPath]/[BuildTarget]'
|
||||
- m_Id: 5cd6c13456d604e5e9a6ad8db28c86ce
|
||||
m_Value: '{UnityEngine.AddressableAssets.Addressables.RuntimePath}/[BuildTarget]'
|
||||
- m_Id: 8e88d36ff360e4cf8a9dc477780bba2c
|
||||
m_Value: ServerData/[BuildTarget]
|
||||
- m_Id: 9c569ce3bfc1f4483b0ddb5a8f38f962
|
||||
m_Value: http://[PrivateIpAddress]:[HostingServicePort]
|
||||
m_ProfileEntryNames:
|
||||
- m_Id: f976e802859f042bcbf93445e0074b55
|
||||
m_Name: BuildTarget
|
||||
m_InlineUsage: 0
|
||||
- m_Id: 1f7171e531b2e45589a60a1df6e16b4b
|
||||
m_Name: Local.BuildPath
|
||||
m_InlineUsage: 0
|
||||
- m_Id: 5cd6c13456d604e5e9a6ad8db28c86ce
|
||||
m_Name: Local.LoadPath
|
||||
m_InlineUsage: 0
|
||||
- m_Id: 8e88d36ff360e4cf8a9dc477780bba2c
|
||||
m_Name: Remote.BuildPath
|
||||
m_InlineUsage: 0
|
||||
- m_Id: 9c569ce3bfc1f4483b0ddb5a8f38f962
|
||||
m_Name: Remote.LoadPath
|
||||
m_InlineUsage: 0
|
||||
m_ProfileVersion: 1
|
||||
m_LabelTable:
|
||||
m_LabelNames:
|
||||
- default
|
||||
m_SchemaTemplates: []
|
||||
m_GroupTemplateObjects:
|
||||
- {fileID: 11400000, guid: f72684a31ef7c4eb4bcbb392351d8f1b, type: 2}
|
||||
m_InitializationObjects: []
|
||||
m_CertificateHandlerType:
|
||||
m_AssemblyName:
|
||||
m_ClassName:
|
||||
m_ActivePlayerDataBuilderIndex: 3
|
||||
m_DataBuilders:
|
||||
- {fileID: 11400000, guid: 8154ac46c760246ebab7bb0f7b17ce89, type: 2}
|
||||
- {fileID: 11400000, guid: e1e69ee250d254e0db33b5ba87dd2884, type: 2}
|
||||
- {fileID: 11400000, guid: 3a012a3e780ad4e6ab0d7d33f619b83e, type: 2}
|
||||
- {fileID: 11400000, guid: 1ba54363b401b443589906a05c077e98, type: 2}
|
||||
m_ActiveProfileId: 803cb393e1ba44d13b8a99db308b84af
|
||||
m_HostingServicesManager:
|
||||
m_HostingServiceInfos: []
|
||||
m_Settings: {fileID: 11400000}
|
||||
m_NextInstanceId: 0
|
||||
m_RegisteredServiceTypeRefs: []
|
||||
m_PingTimeoutInMilliseconds: 5000
|
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 245b0b1b67d1746a3abd2cd19556c98e
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a041a9f8dc90d4976853d9e751d1c32a
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,76 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &-6835223638048365940
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: e5d17a21594effb4e9591490b009e7aa, type: 3}
|
||||
m_Name: BundledAssetGroupSchema
|
||||
m_EditorClassIdentifier:
|
||||
m_Group: {fileID: 0}
|
||||
m_InternalBundleIdMode: 1
|
||||
m_Compression: 1
|
||||
m_IncludeAddressInCatalog: 1
|
||||
m_IncludeGUIDInCatalog: 1
|
||||
m_IncludeLabelsInCatalog: 1
|
||||
m_InternalIdNamingMode: 0
|
||||
m_CacheClearBehavior: 0
|
||||
m_IncludeInBuild: 1
|
||||
m_BundledAssetProviderType:
|
||||
m_AssemblyName:
|
||||
m_ClassName:
|
||||
m_ForceUniqueProvider: 0
|
||||
m_UseAssetBundleCache: 1
|
||||
m_UseAssetBundleCrc: 1
|
||||
m_UseAssetBundleCrcForCachedBundles: 1
|
||||
m_UseUWRForLocalBundles: 0
|
||||
m_Timeout: 0
|
||||
m_ChunkedTransfer: 0
|
||||
m_RedirectLimit: -1
|
||||
m_RetryCount: 0
|
||||
m_BuildPath:
|
||||
m_Id:
|
||||
m_LoadPath:
|
||||
m_Id:
|
||||
m_BundleMode: 0
|
||||
m_AssetBundleProviderType:
|
||||
m_AssemblyName:
|
||||
m_ClassName:
|
||||
m_BundleNaming: 0
|
||||
m_AssetLoadMode: 0
|
||||
--- !u!114 &-2928358181662964713
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 5834b5087d578d24c926ce20cd31e6d6, type: 3}
|
||||
m_Name: ContentUpdateGroupSchema
|
||||
m_EditorClassIdentifier:
|
||||
m_Group: {fileID: 0}
|
||||
m_StaticContent: 0
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 1a3c5d64ac83548c09dd1678b9f6f1cd, type: 3}
|
||||
m_Name: Packed Assets
|
||||
m_EditorClassIdentifier:
|
||||
m_SchemaObjects:
|
||||
- {fileID: -6835223638048365940}
|
||||
- {fileID: -2928358181662964713}
|
||||
m_Description: Pack assets into asset bundles.
|
||||
m_Settings: {fileID: 11400000, guid: 245b0b1b67d1746a3abd2cd19556c98e, type: 2}
|
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f72684a31ef7c4eb4bcbb392351d8f1b
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
BlueWater/Assets/AddressableAssetsData/AssetGroups.meta
Normal file
8
BlueWater/Assets/AddressableAssetsData/AssetGroups.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1afea4179854644d3b2190cf9540b8bd
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,34 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: bbb281ee3bf0b054c82ac2347e9e782c, type: 3}
|
||||
m_Name: Built In Data
|
||||
m_EditorClassIdentifier:
|
||||
m_GroupName: Built In Data
|
||||
m_Data:
|
||||
m_SerializedData: []
|
||||
m_GUID: 6245b25990c9346dbba03572316826cb
|
||||
m_SerializeEntries:
|
||||
- m_GUID: Resources
|
||||
m_Address: Resources
|
||||
m_ReadOnly: 1
|
||||
m_SerializedLabels: []
|
||||
FlaggedDuringContentUpdateRestriction: 0
|
||||
- m_GUID: EditorSceneList
|
||||
m_Address: EditorSceneList
|
||||
m_ReadOnly: 1
|
||||
m_SerializedLabels: []
|
||||
FlaggedDuringContentUpdateRestriction: 0
|
||||
m_ReadOnly: 1
|
||||
m_Settings: {fileID: 11400000, guid: 245b0b1b67d1746a3abd2cd19556c98e, type: 2}
|
||||
m_SchemaSet:
|
||||
m_Schemas:
|
||||
- {fileID: 11400000, guid: 80d5fd8f47ee24ee6b17d9562c6790a0, type: 2}
|
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2c37f0ef7084841f296bbd0e51caeaad
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,25 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: bbb281ee3bf0b054c82ac2347e9e782c, type: 3}
|
||||
m_Name: Default Local Group
|
||||
m_EditorClassIdentifier:
|
||||
m_GroupName: Default Local Group
|
||||
m_Data:
|
||||
m_SerializedData: []
|
||||
m_GUID: 84c68c72d64fe49b4a85c32c0eaeab8b
|
||||
m_SerializeEntries: []
|
||||
m_ReadOnly: 0
|
||||
m_Settings: {fileID: 11400000, guid: 245b0b1b67d1746a3abd2cd19556c98e, type: 2}
|
||||
m_SchemaSet:
|
||||
m_Schemas:
|
||||
- {fileID: 11400000, guid: 9093d20baf9784535bd4fce16ba06da2, type: 2}
|
||||
- {fileID: 11400000, guid: 7fcc2cdffc0c1483ea0ee8b44b37a627, type: 2}
|
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 923dc60ba1f704952b558228228d4e8b
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c5a6796bc06c34ed68072b718ac9bd95
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,17 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: b1487f5d688e4f94f828f879d599dbdc, type: 3}
|
||||
m_Name: Built In Data_PlayerDataGroupSchema
|
||||
m_EditorClassIdentifier:
|
||||
m_Group: {fileID: 11400000, guid: 2c37f0ef7084841f296bbd0e51caeaad, type: 2}
|
||||
m_IncludeResourcesFolders: 1
|
||||
m_IncludeBuildSettingsScenes: 1
|
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 80d5fd8f47ee24ee6b17d9562c6790a0
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,45 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: e5d17a21594effb4e9591490b009e7aa, type: 3}
|
||||
m_Name: Default Local Group_BundledAssetGroupSchema
|
||||
m_EditorClassIdentifier:
|
||||
m_Group: {fileID: 11400000, guid: 923dc60ba1f704952b558228228d4e8b, type: 2}
|
||||
m_InternalBundleIdMode: 1
|
||||
m_Compression: 1
|
||||
m_IncludeAddressInCatalog: 1
|
||||
m_IncludeGUIDInCatalog: 1
|
||||
m_IncludeLabelsInCatalog: 1
|
||||
m_InternalIdNamingMode: 0
|
||||
m_CacheClearBehavior: 0
|
||||
m_IncludeInBuild: 1
|
||||
m_BundledAssetProviderType:
|
||||
m_AssemblyName: Unity.ResourceManager, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||
m_ClassName: UnityEngine.ResourceManagement.ResourceProviders.BundledAssetProvider
|
||||
m_ForceUniqueProvider: 0
|
||||
m_UseAssetBundleCache: 1
|
||||
m_UseAssetBundleCrc: 1
|
||||
m_UseAssetBundleCrcForCachedBundles: 1
|
||||
m_UseUWRForLocalBundles: 0
|
||||
m_Timeout: 0
|
||||
m_ChunkedTransfer: 0
|
||||
m_RedirectLimit: -1
|
||||
m_RetryCount: 0
|
||||
m_BuildPath:
|
||||
m_Id: 1f7171e531b2e45589a60a1df6e16b4b
|
||||
m_LoadPath:
|
||||
m_Id: 5cd6c13456d604e5e9a6ad8db28c86ce
|
||||
m_BundleMode: 0
|
||||
m_AssetBundleProviderType:
|
||||
m_AssemblyName: Unity.ResourceManager, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||
m_ClassName: UnityEngine.ResourceManagement.ResourceProviders.AssetBundleProvider
|
||||
m_BundleNaming: 0
|
||||
m_AssetLoadMode: 0
|
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7fcc2cdffc0c1483ea0ee8b44b37a627
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,16 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 5834b5087d578d24c926ce20cd31e6d6, type: 3}
|
||||
m_Name: Default Local Group_ContentUpdateGroupSchema
|
||||
m_EditorClassIdentifier:
|
||||
m_Group: {fileID: 11400000, guid: 923dc60ba1f704952b558228228d4e8b, type: 2}
|
||||
m_StaticContent: 0
|
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9093d20baf9784535bd4fce16ba06da2
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
BlueWater/Assets/AddressableAssetsData/DataBuilders.meta
Normal file
8
BlueWater/Assets/AddressableAssetsData/DataBuilders.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8ed38878caeb14daf8f8872cfe0a7f91
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,20 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 88d21199f5d473f4db36845f2318f180, type: 3}
|
||||
m_Name: BuildScriptFastMode
|
||||
m_EditorClassIdentifier:
|
||||
instanceProviderType:
|
||||
m_AssemblyName: Unity.ResourceManager, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||
m_ClassName: UnityEngine.ResourceManagement.ResourceProviders.InstanceProvider
|
||||
sceneProviderType:
|
||||
m_AssemblyName: Unity.ResourceManager, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||
m_ClassName: UnityEngine.ResourceManagement.ResourceProviders.SceneProvider
|
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8154ac46c760246ebab7bb0f7b17ce89
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,20 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 3e2e0ffa088c91d41a086d0b8cb16bdc, type: 3}
|
||||
m_Name: BuildScriptPackedMode
|
||||
m_EditorClassIdentifier:
|
||||
instanceProviderType:
|
||||
m_AssemblyName: Unity.ResourceManager, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||
m_ClassName: UnityEngine.ResourceManagement.ResourceProviders.InstanceProvider
|
||||
sceneProviderType:
|
||||
m_AssemblyName: Unity.ResourceManager, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||
m_ClassName: UnityEngine.ResourceManagement.ResourceProviders.SceneProvider
|
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1ba54363b401b443589906a05c077e98
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,20 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: ad8c280d42ee0ed41a27db23b43dd2bf, type: 3}
|
||||
m_Name: BuildScriptPackedPlayMode
|
||||
m_EditorClassIdentifier:
|
||||
instanceProviderType:
|
||||
m_AssemblyName: Unity.ResourceManager, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||
m_ClassName: UnityEngine.ResourceManagement.ResourceProviders.InstanceProvider
|
||||
sceneProviderType:
|
||||
m_AssemblyName: Unity.ResourceManager, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||
m_ClassName: UnityEngine.ResourceManagement.ResourceProviders.SceneProvider
|
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3a012a3e780ad4e6ab0d7d33f619b83e
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,20 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: bb0e4994b34add1409fd8ccaf4a82de5, type: 3}
|
||||
m_Name: BuildScriptVirtualMode
|
||||
m_EditorClassIdentifier:
|
||||
instanceProviderType:
|
||||
m_AssemblyName: Unity.ResourceManager, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||
m_ClassName: UnityEngine.ResourceManagement.ResourceProviders.InstanceProvider
|
||||
sceneProviderType:
|
||||
m_AssemblyName: Unity.ResourceManager, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||
m_ClassName: UnityEngine.ResourceManagement.ResourceProviders.SceneProvider
|
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e1e69ee250d254e0db33b5ba87dd2884
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
15
BlueWater/Assets/AddressableAssetsData/DefaultObject.asset
Normal file
15
BlueWater/Assets/AddressableAssetsData/DefaultObject.asset
Normal file
@ -0,0 +1,15 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 3a189bb168d8d90478a09ea08c2f3d72, type: 3}
|
||||
m_Name: DefaultObject
|
||||
m_EditorClassIdentifier:
|
||||
m_AddressableAssetSettingsGuid: 245b0b1b67d1746a3abd2cd19556c98e
|
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 52ef95baf252a46f2979b3dff5d5a7fa
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
BlueWater/Assets/AstarPathfindingProject.meta
Normal file
8
BlueWater/Assets/AstarPathfindingProject.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e742745a5bd194102893b9275c705823
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,8 @@
|
||||
{
|
||||
"name": "AstarPathfindingProject",
|
||||
"references": [],
|
||||
"optionalUnityReferences": [],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: efa45043feb7e4147a305b73b5cea642
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
9
BlueWater/Assets/AstarPathfindingProject/Behaviors.meta
Normal file
9
BlueWater/Assets/AstarPathfindingProject/Behaviors.meta
Normal file
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5eeb3c5df5ca840d3ae6b93e6b207d74
|
||||
folderAsset: yes
|
||||
timeCreated: 1497206641
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,39 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
namespace Pathfinding {
|
||||
/// <summary>
|
||||
/// Sets the destination of an AI to the position of a specified object.
|
||||
/// This component should be attached to a GameObject together with a movement script such as AIPath, RichAI or AILerp.
|
||||
/// This component will then make the AI move towards the <see cref="target"/> set on this component.
|
||||
///
|
||||
/// See: <see cref="Pathfinding.IAstarAI.destination"/>
|
||||
///
|
||||
/// [Open online documentation to see images]
|
||||
/// </summary>
|
||||
[UniqueComponent(tag = "ai.destination")]
|
||||
[HelpURL("http://arongranberg.com/astar/documentation/stable/class_pathfinding_1_1_a_i_destination_setter.php")]
|
||||
public class AIDestinationSetter : VersionedMonoBehaviour {
|
||||
/// <summary>The object that the AI should move to</summary>
|
||||
public Transform target;
|
||||
IAstarAI ai;
|
||||
|
||||
void OnEnable () {
|
||||
ai = GetComponent<IAstarAI>();
|
||||
// Update the destination right before searching for a path as well.
|
||||
// This is enough in theory, but this script will also update the destination every
|
||||
// frame as the destination is used for debugging and may be used for other things by other
|
||||
// scripts as well. So it makes sense that it is up to date every frame.
|
||||
if (ai != null) ai.onSearchPath += Update;
|
||||
}
|
||||
|
||||
void OnDisable () {
|
||||
if (ai != null) ai.onSearchPath -= Update;
|
||||
}
|
||||
|
||||
/// <summary>Updates the AI's destination every frame</summary>
|
||||
void Update () {
|
||||
if (target != null && ai != null) ai.destination = target.position;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c9679e68a0f1144e79c664d9a11ca121
|
||||
timeCreated: 1495015523
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
59
BlueWater/Assets/AstarPathfindingProject/Behaviors/Patrol.cs
Normal file
59
BlueWater/Assets/AstarPathfindingProject/Behaviors/Patrol.cs
Normal file
@ -0,0 +1,59 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
namespace Pathfinding {
|
||||
/// <summary>
|
||||
/// Simple patrol behavior.
|
||||
/// This will set the destination on the agent so that it moves through the sequence of objects in the <see cref="targets"/> array.
|
||||
/// Upon reaching a target it will wait for <see cref="delay"/> seconds.
|
||||
///
|
||||
/// See: <see cref="Pathfinding.AIDestinationSetter"/>
|
||||
/// See: <see cref="Pathfinding.AIPath"/>
|
||||
/// See: <see cref="Pathfinding.RichAI"/>
|
||||
/// See: <see cref="Pathfinding.AILerp"/>
|
||||
/// </summary>
|
||||
[UniqueComponent(tag = "ai.destination")]
|
||||
[HelpURL("http://arongranberg.com/astar/documentation/stable/class_pathfinding_1_1_patrol.php")]
|
||||
public class Patrol : VersionedMonoBehaviour {
|
||||
/// <summary>Target points to move to in order</summary>
|
||||
public Transform[] targets;
|
||||
|
||||
/// <summary>Time in seconds to wait at each target</summary>
|
||||
public float delay = 0;
|
||||
|
||||
/// <summary>Current target index</summary>
|
||||
int index;
|
||||
|
||||
IAstarAI agent;
|
||||
float switchTime = float.PositiveInfinity;
|
||||
|
||||
protected override void Awake () {
|
||||
base.Awake();
|
||||
agent = GetComponent<IAstarAI>();
|
||||
}
|
||||
|
||||
/// <summary>Update is called once per frame</summary>
|
||||
void Update () {
|
||||
if (targets.Length == 0) return;
|
||||
|
||||
bool search = false;
|
||||
|
||||
// Note: using reachedEndOfPath and pathPending instead of reachedDestination here because
|
||||
// if the destination cannot be reached by the agent, we don't want it to get stuck, we just want it to get as close as possible and then move on.
|
||||
if (agent.reachedEndOfPath && !agent.pathPending && float.IsPositiveInfinity(switchTime)) {
|
||||
switchTime = Time.time + delay;
|
||||
}
|
||||
|
||||
if (Time.time >= switchTime) {
|
||||
index = index + 1;
|
||||
search = true;
|
||||
switchTime = float.PositiveInfinity;
|
||||
}
|
||||
|
||||
index = index % targets.Length;
|
||||
agent.destination = targets[index].position;
|
||||
|
||||
if (search) agent.SearchPath();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 22e6c29e32504465faa943c537d8029b
|
||||
timeCreated: 1495286303
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
2041
BlueWater/Assets/AstarPathfindingProject/CHANGELOG.md
Normal file
2041
BlueWater/Assets/AstarPathfindingProject/CHANGELOG.md
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e271255bdfe8941f9ab0acccbb14dd82
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
2
BlueWater/Assets/AstarPathfindingProject/Core.meta
Normal file
2
BlueWater/Assets/AstarPathfindingProject/Core.meta
Normal file
@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b6b8abb917bca4ce0ad1b26452b3c58d
|
2
BlueWater/Assets/AstarPathfindingProject/Core/AI.meta
Normal file
2
BlueWater/Assets/AstarPathfindingProject/Core/AI.meta
Normal file
@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5ab9be352d07b44e68ad7c1a03eef3a5
|
790
BlueWater/Assets/AstarPathfindingProject/Core/AI/AIBase.cs
Normal file
790
BlueWater/Assets/AstarPathfindingProject/Core/AI/AIBase.cs
Normal file
@ -0,0 +1,790 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
namespace Pathfinding {
|
||||
using Pathfinding.RVO;
|
||||
using Pathfinding.Util;
|
||||
|
||||
/// <summary>
|
||||
/// Base class for AIPath and RichAI.
|
||||
/// This class holds various methods and fields that are common to both AIPath and RichAI.
|
||||
///
|
||||
/// See: <see cref="Pathfinding.AIPath"/>
|
||||
/// See: <see cref="Pathfinding.RichAI"/>
|
||||
/// See: <see cref="Pathfinding.IAstarAI"/> (all movement scripts implement this interface)
|
||||
/// </summary>
|
||||
[RequireComponent(typeof(Seeker))]
|
||||
public abstract class AIBase : VersionedMonoBehaviour {
|
||||
/// <summary>\copydoc Pathfinding::IAstarAI::radius</summary>
|
||||
public float radius = 0.5f;
|
||||
|
||||
/// <summary>\copydoc Pathfinding::IAstarAI::height</summary>
|
||||
public float height = 2;
|
||||
|
||||
/// <summary>
|
||||
/// Determines how often the agent will search for new paths (in seconds).
|
||||
/// The agent will plan a new path to the target every N seconds.
|
||||
///
|
||||
/// If you have fast moving targets or AIs, you might want to set it to a lower value.
|
||||
///
|
||||
/// See: <see cref="shouldRecalculatePath"/>
|
||||
/// See: <see cref="SearchPath"/>
|
||||
///
|
||||
/// Deprecated: This has been renamed to <see cref="autoRepath.period"/>.
|
||||
/// See: <see cref="AutoRepathPolicy"/>
|
||||
/// </summary>
|
||||
public float repathRate {
|
||||
get {
|
||||
return this.autoRepath.period;
|
||||
}
|
||||
set {
|
||||
this.autoRepath.period = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// \copydoc Pathfinding::IAstarAI::canSearch
|
||||
/// Deprecated: This has been superseded by <see cref="autoRepath.mode"/>.
|
||||
/// </summary>
|
||||
public bool canSearch {
|
||||
get {
|
||||
return this.autoRepath.mode != AutoRepathPolicy.Mode.Never;
|
||||
}
|
||||
set {
|
||||
if (value) {
|
||||
if (this.autoRepath.mode == AutoRepathPolicy.Mode.Never) {
|
||||
this.autoRepath.mode = AutoRepathPolicy.Mode.EveryNSeconds;
|
||||
}
|
||||
} else {
|
||||
this.autoRepath.mode = AutoRepathPolicy.Mode.Never;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>\copydoc Pathfinding::IAstarAI::canMove</summary>
|
||||
public bool canMove = true;
|
||||
|
||||
/// <summary>Max speed in world units per second</summary>
|
||||
[UnityEngine.Serialization.FormerlySerializedAs("speed")]
|
||||
public float maxSpeed = 1;
|
||||
|
||||
/// <summary>
|
||||
/// Gravity to use.
|
||||
/// If set to (NaN,NaN,NaN) then Physics.Gravity (configured in the Unity project settings) will be used.
|
||||
/// If set to (0,0,0) then no gravity will be used and no raycast to check for ground penetration will be performed.
|
||||
/// </summary>
|
||||
public Vector3 gravity = new Vector3(float.NaN, float.NaN, float.NaN);
|
||||
|
||||
/// <summary>
|
||||
/// Layer mask to use for ground placement.
|
||||
/// Make sure this does not include the layer of any colliders attached to this gameobject.
|
||||
///
|
||||
/// See: <see cref="gravity"/>
|
||||
/// See: https://docs.unity3d.com/Manual/Layers.html
|
||||
/// </summary>
|
||||
public LayerMask groundMask = -1;
|
||||
|
||||
/// <summary>
|
||||
/// Offset along the Y coordinate for the ground raycast start position.
|
||||
/// Normally the pivot of the character is at the character's feet, but you usually want to fire the raycast
|
||||
/// from the character's center, so this value should be half of the character's height.
|
||||
///
|
||||
/// A green gizmo line will be drawn upwards from the pivot point of the character to indicate where the raycast will start.
|
||||
///
|
||||
/// See: <see cref="gravity"/>
|
||||
/// Deprecated: Use the <see cref="height"/> property instead (2x this value)
|
||||
/// </summary>
|
||||
[System.Obsolete("Use the height property instead (2x this value)")]
|
||||
public float centerOffset {
|
||||
get { return height * 0.5f; } set { height = value * 2; }
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
[HideInInspector]
|
||||
[FormerlySerializedAs("centerOffset")]
|
||||
float centerOffsetCompatibility = float.NaN;
|
||||
|
||||
[SerializeField]
|
||||
[HideInInspector]
|
||||
[UnityEngine.Serialization.FormerlySerializedAs("repathRate")]
|
||||
float repathRateCompatibility = float.NaN;
|
||||
|
||||
[SerializeField]
|
||||
[HideInInspector]
|
||||
[UnityEngine.Serialization.FormerlySerializedAs("canSearch")]
|
||||
[UnityEngine.Serialization.FormerlySerializedAs("repeatedlySearchPaths")]
|
||||
bool canSearchCompability = false;
|
||||
|
||||
/// <summary>
|
||||
/// Determines which direction the agent moves in.
|
||||
/// For 3D games you most likely want the ZAxisIsForward option as that is the convention for 3D games.
|
||||
/// For 2D games you most likely want the YAxisIsForward option as that is the convention for 2D games.
|
||||
///
|
||||
/// Using the YAxisForward option will also allow the agent to assume that the movement will happen in the 2D (XY) plane instead of the XZ plane
|
||||
/// if it does not know. This is important only for the point graph which does not have a well defined up direction. The other built-in graphs (e.g the grid graph)
|
||||
/// will all tell the agent which movement plane it is supposed to use.
|
||||
///
|
||||
/// [Open online documentation to see images]
|
||||
/// </summary>
|
||||
[UnityEngine.Serialization.FormerlySerializedAs("rotationIn2D")]
|
||||
public OrientationMode orientation = OrientationMode.ZAxisForward;
|
||||
|
||||
/// <summary>
|
||||
/// If true, the forward axis of the character will be along the Y axis instead of the Z axis.
|
||||
///
|
||||
/// Deprecated: Use <see cref="orientation"/> instead
|
||||
/// </summary>
|
||||
[System.Obsolete("Use orientation instead")]
|
||||
public bool rotationIn2D {
|
||||
get { return orientation == OrientationMode.YAxisForward; }
|
||||
set { orientation = value ? OrientationMode.YAxisForward : OrientationMode.ZAxisForward; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// If true, the AI will rotate to face the movement direction.
|
||||
/// See: <see cref="orientation"/>
|
||||
/// </summary>
|
||||
public bool enableRotation = true;
|
||||
|
||||
/// <summary>
|
||||
/// Position of the agent.
|
||||
/// If <see cref="updatePosition"/> is true then this value will be synchronized every frame with Transform.position.
|
||||
/// </summary>
|
||||
protected Vector3 simulatedPosition;
|
||||
|
||||
/// <summary>
|
||||
/// Rotation of the agent.
|
||||
/// If <see cref="updateRotation"/> is true then this value will be synchronized every frame with Transform.rotation.
|
||||
/// </summary>
|
||||
protected Quaternion simulatedRotation;
|
||||
|
||||
/// <summary>
|
||||
/// Position of the agent.
|
||||
/// In world space.
|
||||
/// If <see cref="updatePosition"/> is true then this value is idential to transform.position.
|
||||
/// See: <see cref="Teleport"/>
|
||||
/// See: <see cref="Move"/>
|
||||
/// </summary>
|
||||
public Vector3 position { get { return updatePosition ? tr.position : simulatedPosition; } }
|
||||
|
||||
/// <summary>
|
||||
/// Rotation of the agent.
|
||||
/// If <see cref="updateRotation"/> is true then this value is identical to transform.rotation.
|
||||
/// </summary>
|
||||
public Quaternion rotation {
|
||||
get { return updateRotation ? tr.rotation : simulatedRotation; }
|
||||
set {
|
||||
if (updateRotation) {
|
||||
tr.rotation = value;
|
||||
} else {
|
||||
simulatedRotation = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Accumulated movement deltas from the <see cref="Move"/> method</summary>
|
||||
Vector3 accumulatedMovementDelta = Vector3.zero;
|
||||
|
||||
/// <summary>
|
||||
/// Current desired velocity of the agent (does not include local avoidance and physics).
|
||||
/// Lies in the movement plane.
|
||||
/// </summary>
|
||||
protected Vector2 velocity2D;
|
||||
|
||||
/// <summary>
|
||||
/// Velocity due to gravity.
|
||||
/// Perpendicular to the movement plane.
|
||||
///
|
||||
/// When the agent is grounded this may not accurately reflect the velocity of the agent.
|
||||
/// It may be non-zero even though the agent is not moving.
|
||||
/// </summary>
|
||||
protected float verticalVelocity;
|
||||
|
||||
/// <summary>Cached Seeker component</summary>
|
||||
protected Seeker seeker;
|
||||
|
||||
/// <summary>Cached Transform component</summary>
|
||||
protected Transform tr;
|
||||
|
||||
/// <summary>Cached Rigidbody component</summary>
|
||||
protected Rigidbody rigid;
|
||||
|
||||
/// <summary>Cached Rigidbody component</summary>
|
||||
protected Rigidbody2D rigid2D;
|
||||
|
||||
/// <summary>Cached CharacterController component</summary>
|
||||
protected CharacterController controller;
|
||||
|
||||
/// <summary>Cached RVOController component</summary>
|
||||
protected RVOController rvoController;
|
||||
|
||||
/// <summary>
|
||||
/// Plane which this agent is moving in.
|
||||
/// This is used to convert between world space and a movement plane to make it possible to use this script in
|
||||
/// both 2D games and 3D games.
|
||||
/// </summary>
|
||||
public IMovementPlane movementPlane = GraphTransform.identityTransform;
|
||||
|
||||
/// <summary>
|
||||
/// Determines if the character's position should be coupled to the Transform's position.
|
||||
/// If false then all movement calculations will happen as usual, but the object that this component is attached to will not move
|
||||
/// instead only the <see cref="position"/> property will change.
|
||||
///
|
||||
/// This is useful if you want to control the movement of the character using some other means such
|
||||
/// as for example root motion but still want the AI to move freely.
|
||||
/// See: Combined with calling <see cref="MovementUpdate"/> from a separate script instead of it being called automatically one can take a similar approach to what is documented here: https://docs.unity3d.com/Manual/nav-CouplingAnimationAndNavigation.html
|
||||
///
|
||||
/// See: <see cref="canMove"/> which in contrast to this field will disable all movement calculations.
|
||||
/// See: <see cref="updateRotation"/>
|
||||
/// </summary>
|
||||
[System.NonSerialized]
|
||||
public bool updatePosition = true;
|
||||
|
||||
/// <summary>
|
||||
/// Determines if the character's rotation should be coupled to the Transform's rotation.
|
||||
/// If false then all movement calculations will happen as usual, but the object that this component is attached to will not rotate
|
||||
/// instead only the <see cref="rotation"/> property will change.
|
||||
///
|
||||
/// See: <see cref="updatePosition"/>
|
||||
/// </summary>
|
||||
[System.NonSerialized]
|
||||
public bool updateRotation = true;
|
||||
|
||||
/// <summary>
|
||||
/// Determines how the agent recalculates its path automatically.
|
||||
/// This corresponds to the settings under the "Recalculate Paths Automatically" field in the inspector.
|
||||
/// </summary>
|
||||
public AutoRepathPolicy autoRepath = new AutoRepathPolicy();
|
||||
|
||||
/// <summary>Indicates if gravity is used during this frame</summary>
|
||||
protected bool usingGravity { get; set; }
|
||||
|
||||
/// <summary>Delta time used for movement during the last frame</summary>
|
||||
protected float lastDeltaTime;
|
||||
|
||||
/// <summary>Last frame index when <see cref="prevPosition1"/> was updated</summary>
|
||||
protected int prevFrame;
|
||||
|
||||
/// <summary>Position of the character at the end of the last frame</summary>
|
||||
protected Vector3 prevPosition1;
|
||||
|
||||
/// <summary>Position of the character at the end of the frame before the last frame</summary>
|
||||
protected Vector3 prevPosition2;
|
||||
|
||||
/// <summary>Amount which the character wants or tried to move with during the last frame</summary>
|
||||
protected Vector2 lastDeltaPosition;
|
||||
|
||||
/// <summary>Only when the previous path has been calculated should the script consider searching for a new path</summary>
|
||||
protected bool waitingForPathCalculation = false;
|
||||
|
||||
[UnityEngine.Serialization.FormerlySerializedAs("target")][SerializeField][HideInInspector]
|
||||
Transform targetCompatibility;
|
||||
|
||||
/// <summary>
|
||||
/// True if the Start method has been executed.
|
||||
/// Used to test if coroutines should be started in OnEnable to prevent calculating paths
|
||||
/// in the awake stage (or rather before start on frame 0).
|
||||
/// </summary>
|
||||
bool startHasRun = false;
|
||||
|
||||
/// <summary>
|
||||
/// Target to move towards.
|
||||
/// The AI will try to follow/move towards this target.
|
||||
/// It can be a point on the ground where the player has clicked in an RTS for example, or it can be the player object in a zombie game.
|
||||
///
|
||||
/// Deprecated: In 4.1 this will automatically add a <see cref="Pathfinding.AIDestinationSetter"/> component and set the target on that component.
|
||||
/// Try instead to use the <see cref="destination"/> property which does not require a transform to be created as the target or use
|
||||
/// the AIDestinationSetter component directly.
|
||||
/// </summary>
|
||||
[System.Obsolete("Use the destination property or the AIDestinationSetter component instead")]
|
||||
public Transform target {
|
||||
get {
|
||||
var setter = GetComponent<AIDestinationSetter>();
|
||||
return setter != null ? setter.target : null;
|
||||
}
|
||||
set {
|
||||
targetCompatibility = null;
|
||||
var setter = GetComponent<AIDestinationSetter>();
|
||||
if (setter == null) setter = gameObject.AddComponent<AIDestinationSetter>();
|
||||
setter.target = value;
|
||||
destination = value != null ? value.position : new Vector3(float.PositiveInfinity, float.PositiveInfinity, float.PositiveInfinity);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>\copydoc Pathfinding::IAstarAI::destination</summary>
|
||||
public Vector3 destination { get; set; }
|
||||
|
||||
/// <summary>\copydoc Pathfinding::IAstarAI::velocity</summary>
|
||||
public Vector3 velocity {
|
||||
get {
|
||||
return lastDeltaTime > 0.000001f ? (prevPosition1 - prevPosition2) / lastDeltaTime : Vector3.zero;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Velocity that this agent wants to move with.
|
||||
/// Includes gravity and local avoidance if applicable.
|
||||
/// </summary>
|
||||
public Vector3 desiredVelocity { get { return lastDeltaTime > 0.00001f ? movementPlane.ToWorld(lastDeltaPosition / lastDeltaTime, verticalVelocity) : Vector3.zero; } }
|
||||
|
||||
/// <summary>\copydoc Pathfinding::IAstarAI::isStopped</summary>
|
||||
public bool isStopped { get; set; }
|
||||
|
||||
/// <summary>\copydoc Pathfinding::IAstarAI::onSearchPath</summary>
|
||||
public System.Action onSearchPath { get; set; }
|
||||
|
||||
/// <summary>True if the path should be automatically recalculated as soon as possible</summary>
|
||||
protected virtual bool shouldRecalculatePath {
|
||||
get {
|
||||
return !waitingForPathCalculation && autoRepath.ShouldRecalculatePath(position, radius, destination);
|
||||
}
|
||||
}
|
||||
|
||||
protected AIBase () {
|
||||
// Note that this needs to be set here in the constructor and not in e.g Awake
|
||||
// because it is possible that other code runs and sets the destination property
|
||||
// before the Awake method on this script runs.
|
||||
destination = new Vector3(float.PositiveInfinity, float.PositiveInfinity, float.PositiveInfinity);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks for any attached components like RVOController and CharacterController etc.
|
||||
///
|
||||
/// This is done during <see cref="OnEnable"/>. If you are adding/removing components during runtime you may want to call this function
|
||||
/// to make sure that this script finds them. It is unfortunately prohibitive from a performance standpoint to look for components every frame.
|
||||
/// </summary>
|
||||
public virtual void FindComponents () {
|
||||
tr = transform;
|
||||
seeker = GetComponent<Seeker>();
|
||||
rvoController = GetComponent<RVOController>();
|
||||
// Find attached movement components
|
||||
controller = GetComponent<CharacterController>();
|
||||
rigid = GetComponent<Rigidbody>();
|
||||
rigid2D = GetComponent<Rigidbody2D>();
|
||||
}
|
||||
|
||||
/// <summary>Called when the component is enabled</summary>
|
||||
protected virtual void OnEnable () {
|
||||
FindComponents();
|
||||
// Make sure we receive callbacks when paths are calculated
|
||||
seeker.pathCallback += OnPathComplete;
|
||||
Init();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Starts searching for paths.
|
||||
/// If you override this method you should in most cases call base.Start () at the start of it.
|
||||
/// See: <see cref="Init"/>
|
||||
/// </summary>
|
||||
protected virtual void Start () {
|
||||
startHasRun = true;
|
||||
Init();
|
||||
}
|
||||
|
||||
void Init () {
|
||||
if (startHasRun) {
|
||||
// Clamp the agent to the navmesh (which is what the Teleport call will do essentially. Though only some movement scripts require this, like RichAI).
|
||||
// The Teleport call will also make sure some variables are properly initialized (like #prevPosition1 and #prevPosition2)
|
||||
if (canMove) Teleport(position, false);
|
||||
autoRepath.Reset();
|
||||
if (shouldRecalculatePath) SearchPath();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>\copydoc Pathfinding::IAstarAI::Teleport</summary>
|
||||
public virtual void Teleport (Vector3 newPosition, bool clearPath = true) {
|
||||
if (clearPath) ClearPath();
|
||||
prevPosition1 = prevPosition2 = simulatedPosition = newPosition;
|
||||
if (updatePosition) tr.position = newPosition;
|
||||
if (rvoController != null) rvoController.Move(Vector3.zero);
|
||||
if (clearPath) SearchPath();
|
||||
}
|
||||
|
||||
protected void CancelCurrentPathRequest () {
|
||||
waitingForPathCalculation = false;
|
||||
// Abort calculation of the current path
|
||||
if (seeker != null) seeker.CancelCurrentPathRequest();
|
||||
}
|
||||
|
||||
protected virtual void OnDisable () {
|
||||
ClearPath();
|
||||
|
||||
// Make sure we no longer receive callbacks when paths complete
|
||||
seeker.pathCallback -= OnPathComplete;
|
||||
|
||||
velocity2D = Vector3.zero;
|
||||
accumulatedMovementDelta = Vector3.zero;
|
||||
verticalVelocity = 0f;
|
||||
lastDeltaTime = 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called every frame.
|
||||
/// If no rigidbodies are used then all movement happens here.
|
||||
/// </summary>
|
||||
protected virtual void Update () {
|
||||
if (shouldRecalculatePath) SearchPath();
|
||||
|
||||
// If gravity is used depends on a lot of things.
|
||||
// For example when a non-kinematic rigidbody is used then the rigidbody will apply the gravity itself
|
||||
// Note that the gravity can contain NaN's, which is why the comparison uses !(a==b) instead of just a!=b.
|
||||
usingGravity = !(gravity == Vector3.zero) && (!updatePosition || ((rigid == null || rigid.isKinematic) && (rigid2D == null || rigid2D.isKinematic)));
|
||||
if (rigid == null && rigid2D == null && canMove) {
|
||||
Vector3 nextPosition;
|
||||
Quaternion nextRotation;
|
||||
MovementUpdate(Time.deltaTime, out nextPosition, out nextRotation);
|
||||
FinalizeMovement(nextPosition, nextRotation);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called every physics update.
|
||||
/// If rigidbodies are used then all movement happens here.
|
||||
/// </summary>
|
||||
protected virtual void FixedUpdate () {
|
||||
if (!(rigid == null && rigid2D == null) && canMove) {
|
||||
Vector3 nextPosition;
|
||||
Quaternion nextRotation;
|
||||
MovementUpdate(Time.fixedDeltaTime, out nextPosition, out nextRotation);
|
||||
FinalizeMovement(nextPosition, nextRotation);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>\copydoc Pathfinding::IAstarAI::MovementUpdate</summary>
|
||||
public void MovementUpdate (float deltaTime, out Vector3 nextPosition, out Quaternion nextRotation) {
|
||||
lastDeltaTime = deltaTime;
|
||||
MovementUpdateInternal(deltaTime, out nextPosition, out nextRotation);
|
||||
}
|
||||
|
||||
/// <summary>Called during either Update or FixedUpdate depending on if rigidbodies are used for movement or not</summary>
|
||||
protected abstract void MovementUpdateInternal(float deltaTime, out Vector3 nextPosition, out Quaternion nextRotation);
|
||||
|
||||
/// <summary>
|
||||
/// Outputs the start point and end point of the next automatic path request.
|
||||
/// This is a separate method to make it easy for subclasses to swap out the endpoints
|
||||
/// of path requests. For example the <see cref="LocalSpaceRichAI"/> script which requires the endpoints
|
||||
/// to be transformed to graph space first.
|
||||
/// </summary>
|
||||
protected virtual void CalculatePathRequestEndpoints (out Vector3 start, out Vector3 end) {
|
||||
start = GetFeetPosition();
|
||||
end = destination;
|
||||
}
|
||||
|
||||
/// <summary>\copydoc Pathfinding::IAstarAI::SearchPath</summary>
|
||||
public virtual void SearchPath () {
|
||||
if (float.IsPositiveInfinity(destination.x)) return;
|
||||
if (onSearchPath != null) onSearchPath();
|
||||
|
||||
Vector3 start, end;
|
||||
CalculatePathRequestEndpoints(out start, out end);
|
||||
|
||||
// Request a path to be calculated from our current position to the destination
|
||||
ABPath p = ABPath.Construct(start, end, null);
|
||||
SetPath(p, false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Position of the base of the character.
|
||||
/// This is used for pathfinding as the character's pivot point is sometimes placed
|
||||
/// at the center of the character instead of near the feet. In a building with multiple floors
|
||||
/// the center of a character may in some scenarios be closer to the navmesh on the floor above
|
||||
/// than to the floor below which could cause an incorrect path to be calculated.
|
||||
/// To solve this the start point of the requested paths is always at the base of the character.
|
||||
/// </summary>
|
||||
public virtual Vector3 GetFeetPosition () {
|
||||
return position;
|
||||
}
|
||||
|
||||
/// <summary>Called when a requested path has been calculated</summary>
|
||||
protected abstract void OnPathComplete(Path newPath);
|
||||
|
||||
/// <summary>
|
||||
/// Clears the current path of the agent.
|
||||
///
|
||||
/// Usually invoked using <see cref="SetPath(null)"/>
|
||||
///
|
||||
/// See: <see cref="SetPath"/>
|
||||
/// See: <see cref="isStopped"/>
|
||||
/// </summary>
|
||||
protected abstract void ClearPath();
|
||||
|
||||
/// <summary>\copydoc Pathfinding::IAstarAI::SetPath</summary>
|
||||
public void SetPath (Path path, bool updateDestinationFromPath = true) {
|
||||
if (updateDestinationFromPath && path is ABPath abPath && !(path is RandomPath)) {
|
||||
this.destination = abPath.originalEndPoint;
|
||||
}
|
||||
|
||||
if (path == null) {
|
||||
CancelCurrentPathRequest();
|
||||
ClearPath();
|
||||
} else if (path.PipelineState == PathState.Created) {
|
||||
// Path has not started calculation yet
|
||||
waitingForPathCalculation = true;
|
||||
seeker.CancelCurrentPathRequest();
|
||||
seeker.StartPath(path);
|
||||
autoRepath.DidRecalculatePath(destination);
|
||||
} else if (path.PipelineState == PathState.Returned) {
|
||||
// Path has already been calculated
|
||||
|
||||
// We might be calculating another path at the same time, and we don't want that path to override this one. So cancel it.
|
||||
if (seeker.GetCurrentPath() != path) seeker.CancelCurrentPathRequest();
|
||||
else throw new System.ArgumentException("If you calculate the path using seeker.StartPath then this script will pick up the calculated path anyway as it listens for all paths the Seeker finishes calculating. You should not call SetPath in that case.");
|
||||
|
||||
OnPathComplete(path);
|
||||
} else {
|
||||
// Path calculation has been started, but it is not yet complete. Cannot really handle this.
|
||||
throw new System.ArgumentException("You must call the SetPath method with a path that either has been completely calculated or one whose path calculation has not been started at all. It looks like the path calculation for the path you tried to use has been started, but is not yet finished.");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Accelerates the agent downwards.
|
||||
/// See: <see cref="verticalVelocity"/>
|
||||
/// See: <see cref="gravity"/>
|
||||
/// </summary>
|
||||
protected void ApplyGravity (float deltaTime) {
|
||||
// Apply gravity
|
||||
if (usingGravity) {
|
||||
float verticalGravity;
|
||||
velocity2D += movementPlane.ToPlane(deltaTime * (float.IsNaN(gravity.x) ? Physics.gravity : gravity), out verticalGravity);
|
||||
verticalVelocity += verticalGravity;
|
||||
} else {
|
||||
verticalVelocity = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Calculates how far to move during a single frame</summary>
|
||||
protected Vector2 CalculateDeltaToMoveThisFrame (Vector2 position, float distanceToEndOfPath, float deltaTime) {
|
||||
if (rvoController != null && rvoController.enabled) {
|
||||
// Use RVOController to get a processed delta position
|
||||
// such that collisions will be avoided if possible
|
||||
return movementPlane.ToPlane(rvoController.CalculateMovementDelta(movementPlane.ToWorld(position, 0), deltaTime));
|
||||
}
|
||||
// Direction and distance to move during this frame
|
||||
return Vector2.ClampMagnitude(velocity2D * deltaTime, distanceToEndOfPath);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Simulates rotating the agent towards the specified direction and returns the new rotation.
|
||||
///
|
||||
/// Note that this only calculates a new rotation, it does not change the actual rotation of the agent.
|
||||
/// Useful when you are handling movement externally using <see cref="FinalizeMovement"/> but you want to use the built-in rotation code.
|
||||
///
|
||||
/// See: <see cref="orientation"/>
|
||||
/// </summary>
|
||||
/// <param name="direction">Direction in world space to rotate towards.</param>
|
||||
/// <param name="maxDegrees">Maximum number of degrees to rotate this frame.</param>
|
||||
public Quaternion SimulateRotationTowards (Vector3 direction, float maxDegrees) {
|
||||
return SimulateRotationTowards(movementPlane.ToPlane(direction), maxDegrees);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Simulates rotating the agent towards the specified direction and returns the new rotation.
|
||||
///
|
||||
/// Note that this only calculates a new rotation, it does not change the actual rotation of the agent.
|
||||
///
|
||||
/// See: <see cref="orientation"/>
|
||||
/// See: <see cref="movementPlane"/>
|
||||
/// </summary>
|
||||
/// <param name="direction">Direction in the movement plane to rotate towards.</param>
|
||||
/// <param name="maxDegrees">Maximum number of degrees to rotate this frame.</param>
|
||||
protected Quaternion SimulateRotationTowards (Vector2 direction, float maxDegrees) {
|
||||
if (direction != Vector2.zero) {
|
||||
Quaternion targetRotation = Quaternion.LookRotation(movementPlane.ToWorld(direction, 0), movementPlane.ToWorld(Vector2.zero, 1));
|
||||
// This causes the character to only rotate around the Z axis
|
||||
if (orientation == OrientationMode.YAxisForward) targetRotation *= Quaternion.Euler(90, 0, 0);
|
||||
return Quaternion.RotateTowards(simulatedRotation, targetRotation, maxDegrees);
|
||||
}
|
||||
return simulatedRotation;
|
||||
}
|
||||
|
||||
/// <summary>\copydoc Pathfinding::IAstarAI::Move</summary>
|
||||
public virtual void Move (Vector3 deltaPosition) {
|
||||
accumulatedMovementDelta += deltaPosition;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Moves the agent to a position.
|
||||
///
|
||||
/// This is used if you want to override how the agent moves. For example if you are using
|
||||
/// root motion with Mecanim.
|
||||
///
|
||||
/// This will use a CharacterController, Rigidbody, Rigidbody2D or the Transform component depending on what options
|
||||
/// are available.
|
||||
///
|
||||
/// The agent will be clamped to the navmesh after the movement (if such information is available, generally this is only done by the RichAI component).
|
||||
///
|
||||
/// See: <see cref="MovementUpdate"/> for some example code.
|
||||
/// See: <see cref="controller"/>, <see cref="rigid"/>, <see cref="rigid2D"/>
|
||||
/// </summary>
|
||||
/// <param name="nextPosition">New position of the agent.</param>
|
||||
/// <param name="nextRotation">New rotation of the agent. If #enableRotation is false then this parameter will be ignored.</param>
|
||||
public virtual void FinalizeMovement (Vector3 nextPosition, Quaternion nextRotation) {
|
||||
if (enableRotation) FinalizeRotation(nextRotation);
|
||||
FinalizePosition(nextPosition);
|
||||
}
|
||||
|
||||
void FinalizeRotation (Quaternion nextRotation) {
|
||||
simulatedRotation = nextRotation;
|
||||
if (updateRotation) {
|
||||
if (rigid != null) rigid.MoveRotation(nextRotation);
|
||||
else if (rigid2D != null) rigid2D.MoveRotation(nextRotation.eulerAngles.z);
|
||||
else tr.rotation = nextRotation;
|
||||
}
|
||||
}
|
||||
|
||||
void FinalizePosition (Vector3 nextPosition) {
|
||||
// Use a local variable, it is significantly faster
|
||||
Vector3 currentPosition = simulatedPosition;
|
||||
bool positionDirty1 = false;
|
||||
|
||||
if (controller != null && controller.enabled && updatePosition) {
|
||||
// Use CharacterController
|
||||
// The Transform may not be at #position if it was outside the navmesh and had to be moved to the closest valid position
|
||||
tr.position = currentPosition;
|
||||
controller.Move((nextPosition - currentPosition) + accumulatedMovementDelta);
|
||||
// Grab the position after the movement to be able to take physics into account
|
||||
// TODO: Add this into the clampedPosition calculation below to make RVO better respond to physics
|
||||
currentPosition = tr.position;
|
||||
if (controller.isGrounded) verticalVelocity = 0;
|
||||
} else {
|
||||
// Use Transform, Rigidbody, Rigidbody2D or nothing at all (if updatePosition = false)
|
||||
float lastElevation;
|
||||
movementPlane.ToPlane(currentPosition, out lastElevation);
|
||||
currentPosition = nextPosition + accumulatedMovementDelta;
|
||||
|
||||
// Position the character on the ground
|
||||
if (usingGravity) currentPosition = RaycastPosition(currentPosition, lastElevation);
|
||||
positionDirty1 = true;
|
||||
}
|
||||
|
||||
// Clamp the position to the navmesh after movement is done
|
||||
bool positionDirty2 = false;
|
||||
currentPosition = ClampToNavmesh(currentPosition, out positionDirty2);
|
||||
|
||||
// Assign the final position to the character if we haven't already set it (mostly for performance, setting the position can be slow)
|
||||
if ((positionDirty1 || positionDirty2) && updatePosition) {
|
||||
// Note that rigid.MovePosition may or may not move the character immediately.
|
||||
// Check the Unity documentation for the special cases.
|
||||
if (rigid != null) rigid.MovePosition(currentPosition);
|
||||
else if (rigid2D != null) rigid2D.MovePosition(currentPosition);
|
||||
else tr.position = currentPosition;
|
||||
}
|
||||
|
||||
accumulatedMovementDelta = Vector3.zero;
|
||||
simulatedPosition = currentPosition;
|
||||
UpdateVelocity();
|
||||
}
|
||||
|
||||
protected void UpdateVelocity () {
|
||||
var currentFrame = Time.frameCount;
|
||||
|
||||
if (currentFrame != prevFrame) prevPosition2 = prevPosition1;
|
||||
prevPosition1 = position;
|
||||
prevFrame = currentFrame;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constrains the character's position to lie on the navmesh.
|
||||
/// Not all movement scripts have support for this.
|
||||
///
|
||||
/// Returns: New position of the character that has been clamped to the navmesh.
|
||||
/// </summary>
|
||||
/// <param name="position">Current position of the character.</param>
|
||||
/// <param name="positionChanged">True if the character's position was modified by this method.</param>
|
||||
protected virtual Vector3 ClampToNavmesh (Vector3 position, out bool positionChanged) {
|
||||
positionChanged = false;
|
||||
return position;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the character is grounded and prevents ground penetration.
|
||||
///
|
||||
/// Sets <see cref="verticalVelocity"/> to zero if the character is grounded.
|
||||
///
|
||||
/// Returns: The new position of the character.
|
||||
/// </summary>
|
||||
/// <param name="position">Position of the character in the world.</param>
|
||||
/// <param name="lastElevation">Elevation coordinate before the agent was moved. This is along the 'up' axis of the #movementPlane.</param>
|
||||
protected Vector3 RaycastPosition (Vector3 position, float lastElevation) {
|
||||
RaycastHit hit;
|
||||
float elevation;
|
||||
|
||||
movementPlane.ToPlane(position, out elevation);
|
||||
float rayLength = tr.localScale.y * height * 0.5f + Mathf.Max(0, lastElevation-elevation);
|
||||
Vector3 rayOffset = movementPlane.ToWorld(Vector2.zero, rayLength);
|
||||
|
||||
if (Physics.Raycast(position + rayOffset, -rayOffset, out hit, rayLength, groundMask, QueryTriggerInteraction.Ignore)) {
|
||||
// Grounded
|
||||
// Make the vertical velocity fall off exponentially. This is reasonable from a physical standpoint as characters
|
||||
// are not completely stiff and touching the ground will not immediately negate all velocity downwards. The AI will
|
||||
// stop moving completely due to the raycast penetration test but it will still *try* to move downwards. This helps
|
||||
// significantly when moving down along slopes as if the vertical velocity would be set to zero when the character
|
||||
// was grounded it would lead to a kind of 'bouncing' behavior (try it, it's hard to explain). Ideally this should
|
||||
// use a more physically correct formula but this is a good approximation and is much more performant. The constant
|
||||
// '5' in the expression below determines how quickly it converges but high values can lead to too much noise.
|
||||
verticalVelocity *= System.Math.Max(0, 1 - 5 * lastDeltaTime);
|
||||
return hit.point;
|
||||
}
|
||||
return position;
|
||||
}
|
||||
|
||||
protected virtual void OnDrawGizmosSelected () {
|
||||
// When selected in the Unity inspector it's nice to make the component react instantly if
|
||||
// any other components are attached/detached or enabled/disabled.
|
||||
// We don't want to do this normally every frame because that would be expensive.
|
||||
if (Application.isPlaying) FindComponents();
|
||||
}
|
||||
|
||||
public static readonly Color ShapeGizmoColor = new Color(240/255f, 213/255f, 30/255f);
|
||||
|
||||
protected virtual void OnDrawGizmos () {
|
||||
if (!Application.isPlaying || !enabled) FindComponents();
|
||||
|
||||
var color = ShapeGizmoColor;
|
||||
if (rvoController != null && rvoController.locked) color *= 0.5f;
|
||||
if (orientation == OrientationMode.YAxisForward) {
|
||||
Draw.Gizmos.Cylinder(position, Vector3.forward, 0, radius * tr.localScale.x, color);
|
||||
} else {
|
||||
Draw.Gizmos.Cylinder(position, rotation * Vector3.up, tr.localScale.y * height, radius * tr.localScale.x, color);
|
||||
}
|
||||
|
||||
if (!float.IsPositiveInfinity(destination.x) && Application.isPlaying) Draw.Gizmos.CircleXZ(destination, 0.2f, Color.blue);
|
||||
|
||||
autoRepath.DrawGizmos(position, radius);
|
||||
}
|
||||
|
||||
protected override void Reset () {
|
||||
ResetShape();
|
||||
base.Reset();
|
||||
}
|
||||
|
||||
void ResetShape () {
|
||||
var cc = GetComponent<CharacterController>();
|
||||
|
||||
if (cc != null) {
|
||||
radius = cc.radius;
|
||||
height = Mathf.Max(radius*2, cc.height);
|
||||
}
|
||||
}
|
||||
|
||||
protected override int OnUpgradeSerializedData (int version, bool unityThread) {
|
||||
if (unityThread && !float.IsNaN(centerOffsetCompatibility)) {
|
||||
height = centerOffsetCompatibility*2;
|
||||
ResetShape();
|
||||
var rvo = GetComponent<RVOController>();
|
||||
if (rvo != null) radius = rvo.radiusBackingField;
|
||||
centerOffsetCompatibility = float.NaN;
|
||||
}
|
||||
#pragma warning disable 618
|
||||
if (unityThread && targetCompatibility != null) target = targetCompatibility;
|
||||
#pragma warning restore 618
|
||||
if (version <= 3) {
|
||||
repathRate = repathRateCompatibility;
|
||||
canSearch = canSearchCompability;
|
||||
}
|
||||
return 5;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a08f67bbe580e4ddfaebd06363c9cc97
|
||||
timeCreated: 1496932372
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 100
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
715
BlueWater/Assets/AstarPathfindingProject/Core/AI/AILerp.cs
Normal file
715
BlueWater/Assets/AstarPathfindingProject/Core/AI/AILerp.cs
Normal file
@ -0,0 +1,715 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Pathfinding {
|
||||
using Pathfinding.Util;
|
||||
|
||||
/// <summary>
|
||||
/// Linearly interpolating movement script.
|
||||
///
|
||||
/// [Open online documentation to see images]
|
||||
///
|
||||
/// This movement script will follow the path exactly, it uses linear interpolation to move between the waypoints in the path.
|
||||
/// This is desirable for some types of games.
|
||||
/// It also works in 2D.
|
||||
///
|
||||
/// See: You can see an example of this script in action in the example scene called Example15_2D.
|
||||
///
|
||||
/// \section rec Configuration
|
||||
/// \subsection rec-snapped Recommended setup for movement along connections
|
||||
///
|
||||
/// This depends on what type of movement you are aiming for.
|
||||
/// If you are aiming for movement where the unit follows the path exactly and move only along the graph connections on a grid/point graph.
|
||||
/// I recommend that you adjust the StartEndModifier on the Seeker component: set the 'Start Point Snapping' field to 'NodeConnection' and the 'End Point Snapping' field to 'SnapToNode'.
|
||||
/// [Open online documentation to see images]
|
||||
/// [Open online documentation to see images]
|
||||
///
|
||||
/// \subsection rec-smooth Recommended setup for smooth movement
|
||||
/// If you on the other hand want smoother movement I recommend setting 'Start Point Snapping' and 'End Point Snapping' to 'ClosestOnNode' and to add the Simple Smooth Modifier to the GameObject as well.
|
||||
/// Alternatively you can use the <see cref="Pathfinding.FunnelModifier Funnel"/> which works better on navmesh/recast graphs or the <see cref="Pathfinding.RaycastModifier"/>.
|
||||
///
|
||||
/// You should not combine the Simple Smooth Modifier or the Funnel Modifier with the NodeConnection snapping mode. This may lead to very odd behavior.
|
||||
///
|
||||
/// [Open online documentation to see images]
|
||||
/// [Open online documentation to see images]
|
||||
/// You may also want to tweak the <see cref="rotationSpeed"/>.
|
||||
/// </summary>
|
||||
[RequireComponent(typeof(Seeker))]
|
||||
[AddComponentMenu("Pathfinding/AI/AILerp (2D,3D)")]
|
||||
[HelpURL("http://arongranberg.com/astar/documentation/stable/class_pathfinding_1_1_a_i_lerp.php")]
|
||||
public class AILerp : VersionedMonoBehaviour, IAstarAI {
|
||||
/// <summary>
|
||||
/// Determines how often it will search for new paths.
|
||||
/// If you have fast moving targets or AIs, you might want to set it to a lower value.
|
||||
/// The value is in seconds between path requests.
|
||||
///
|
||||
/// Deprecated: This has been renamed to <see cref="autoRepath.period"/>.
|
||||
/// See: <see cref="AutoRepathPolicy"/>
|
||||
/// </summary>
|
||||
public float repathRate {
|
||||
get {
|
||||
return this.autoRepath.period;
|
||||
}
|
||||
set {
|
||||
this.autoRepath.period = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// \copydoc Pathfinding::IAstarAI::canSearch
|
||||
/// Deprecated: This has been superseded by <see cref="autoRepath.mode"/>.
|
||||
/// </summary>
|
||||
public bool canSearch {
|
||||
get {
|
||||
return this.autoRepath.mode != AutoRepathPolicy.Mode.Never;
|
||||
}
|
||||
set {
|
||||
this.autoRepath.mode = value ? AutoRepathPolicy.Mode.EveryNSeconds : AutoRepathPolicy.Mode.Never;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines how the agent recalculates its path automatically.
|
||||
/// This corresponds to the settings under the "Recalculate Paths Automatically" field in the inspector.
|
||||
/// </summary>
|
||||
public AutoRepathPolicy autoRepath = new AutoRepathPolicy();
|
||||
|
||||
/// <summary>\copydoc Pathfinding::IAstarAI::canMove</summary>
|
||||
public bool canMove = true;
|
||||
|
||||
/// <summary>Speed in world units</summary>
|
||||
public float speed = 3;
|
||||
|
||||
/// <summary>
|
||||
/// Determines which direction the agent moves in.
|
||||
/// For 3D games you most likely want the ZAxisIsForward option as that is the convention for 3D games.
|
||||
/// For 2D games you most likely want the YAxisIsForward option as that is the convention for 2D games.
|
||||
///
|
||||
/// Using the YAxisForward option will also allow the agent to assume that the movement will happen in the 2D (XY) plane instead of the XZ plane
|
||||
/// if it does not know. This is important only for the point graph which does not have a well defined up direction. The other built-in graphs (e.g the grid graph)
|
||||
/// will all tell the agent which movement plane it is supposed to use.
|
||||
///
|
||||
/// [Open online documentation to see images]
|
||||
/// </summary>
|
||||
[UnityEngine.Serialization.FormerlySerializedAs("rotationIn2D")]
|
||||
public OrientationMode orientation = OrientationMode.ZAxisForward;
|
||||
|
||||
/// <summary>
|
||||
/// If true, the forward axis of the character will be along the Y axis instead of the Z axis.
|
||||
///
|
||||
/// Deprecated: Use <see cref="orientation"/> instead
|
||||
/// </summary>
|
||||
[System.Obsolete("Use orientation instead")]
|
||||
public bool rotationIn2D {
|
||||
get { return orientation == OrientationMode.YAxisForward; }
|
||||
set { orientation = value ? OrientationMode.YAxisForward : OrientationMode.ZAxisForward; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// If true, the AI will rotate to face the movement direction.
|
||||
/// See: <see cref="orientation"/>
|
||||
/// </summary>
|
||||
public bool enableRotation = true;
|
||||
|
||||
/// <summary>How quickly to rotate</summary>
|
||||
public float rotationSpeed = 10;
|
||||
|
||||
/// <summary>
|
||||
/// If true, some interpolation will be done when a new path has been calculated.
|
||||
/// This is used to avoid short distance teleportation.
|
||||
/// See: <see cref="switchPathInterpolationSpeed"/>
|
||||
/// </summary>
|
||||
public bool interpolatePathSwitches = true;
|
||||
|
||||
/// <summary>
|
||||
/// How quickly to interpolate to the new path.
|
||||
/// See: <see cref="interpolatePathSwitches"/>
|
||||
/// </summary>
|
||||
public float switchPathInterpolationSpeed = 5;
|
||||
|
||||
/// <summary>True if the end of the current path has been reached</summary>
|
||||
public bool reachedEndOfPath { get; private set; }
|
||||
|
||||
/// <summary>\copydoc Pathfinding::IAstarAI::reachedDestination</summary>
|
||||
public bool reachedDestination {
|
||||
get {
|
||||
if (!reachedEndOfPath || !interpolator.valid) return false;
|
||||
// Note: distanceToSteeringTarget is the distance to the end of the path when approachingPathEndpoint is true
|
||||
var dir = destination - interpolator.endPoint;
|
||||
// Ignore either the y or z coordinate depending on if we are using 2D mode or not
|
||||
if (orientation == OrientationMode.YAxisForward) dir.z = 0;
|
||||
else dir.y = 0;
|
||||
|
||||
// Check against using a very small margin
|
||||
// In theory a check against 0 should be done, but this will be a bit more resilient against targets that move slowly or maybe jitter around due to floating point errors.
|
||||
if (remainingDistance + dir.magnitude >= 0.05f) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public Vector3 destination { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Determines if the character's position should be coupled to the Transform's position.
|
||||
/// If false then all movement calculations will happen as usual, but the object that this component is attached to will not move
|
||||
/// instead only the <see cref="position"/> property will change.
|
||||
///
|
||||
/// See: <see cref="canMove"/> which in contrast to this field will disable all movement calculations.
|
||||
/// See: <see cref="updateRotation"/>
|
||||
/// </summary>
|
||||
[System.NonSerialized]
|
||||
public bool updatePosition = true;
|
||||
|
||||
/// <summary>
|
||||
/// Determines if the character's rotation should be coupled to the Transform's rotation.
|
||||
/// If false then all movement calculations will happen as usual, but the object that this component is attached to will not rotate
|
||||
/// instead only the <see cref="rotation"/> property will change.
|
||||
///
|
||||
/// See: <see cref="updatePosition"/>
|
||||
/// </summary>
|
||||
[System.NonSerialized]
|
||||
public bool updateRotation = true;
|
||||
|
||||
/// <summary>
|
||||
/// Target to move towards.
|
||||
/// The AI will try to follow/move towards this target.
|
||||
/// It can be a point on the ground where the player has clicked in an RTS for example, or it can be the player object in a zombie game.
|
||||
///
|
||||
/// Deprecated: In 4.0 this will automatically add a <see cref="Pathfinding.AIDestinationSetter"/> component and set the target on that component.
|
||||
/// Try instead to use the <see cref="destination"/> property which does not require a transform to be created as the target or use
|
||||
/// the AIDestinationSetter component directly.
|
||||
/// </summary>
|
||||
[System.Obsolete("Use the destination property or the AIDestinationSetter component instead")]
|
||||
public Transform target {
|
||||
get {
|
||||
var setter = GetComponent<AIDestinationSetter>();
|
||||
return setter != null ? setter.target : null;
|
||||
}
|
||||
set {
|
||||
targetCompatibility = null;
|
||||
var setter = GetComponent<AIDestinationSetter>();
|
||||
if (setter == null) setter = gameObject.AddComponent<AIDestinationSetter>();
|
||||
setter.target = value;
|
||||
destination = value != null ? value.position : new Vector3(float.PositiveInfinity, float.PositiveInfinity, float.PositiveInfinity);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>\copydoc Pathfinding::IAstarAI::position</summary>
|
||||
public Vector3 position { get { return updatePosition ? tr.position : simulatedPosition; } }
|
||||
|
||||
/// <summary>\copydoc Pathfinding::IAstarAI::rotation</summary>
|
||||
public Quaternion rotation {
|
||||
get { return updateRotation ? tr.rotation : simulatedRotation; }
|
||||
set {
|
||||
if (updateRotation) {
|
||||
tr.rotation = value;
|
||||
} else {
|
||||
simulatedRotation = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#region IAstarAI implementation
|
||||
|
||||
/// <summary>\copydoc Pathfinding::IAstarAI::Move</summary>
|
||||
void IAstarAI.Move (Vector3 deltaPosition) {
|
||||
// This script does not know the concept of being away from the path that it is following
|
||||
// so this call will be ignored (as is also mentioned in the documentation).
|
||||
}
|
||||
|
||||
/// <summary>\copydoc Pathfinding::IAstarAI::radius</summary>
|
||||
float IAstarAI.radius { get { return 0; } set {} }
|
||||
|
||||
/// <summary>\copydoc Pathfinding::IAstarAI::height</summary>
|
||||
float IAstarAI.height { get { return 0; } set {} }
|
||||
|
||||
/// <summary>\copydoc Pathfinding::IAstarAI::maxSpeed</summary>
|
||||
float IAstarAI.maxSpeed { get { return speed; } set { speed = value; } }
|
||||
|
||||
/// <summary>\copydoc Pathfinding::IAstarAI::canSearch</summary>
|
||||
bool IAstarAI.canSearch { get { return canSearch; } set { canSearch = value; } }
|
||||
|
||||
/// <summary>\copydoc Pathfinding::IAstarAI::canMove</summary>
|
||||
bool IAstarAI.canMove { get { return canMove; } set { canMove = value; } }
|
||||
|
||||
/// <summary>\copydoc Pathfinding::IAstarAI::velocity</summary>
|
||||
public Vector3 velocity {
|
||||
get {
|
||||
return Time.deltaTime > 0.00001f ? (previousPosition1 - previousPosition2) / Time.deltaTime : Vector3.zero;
|
||||
}
|
||||
}
|
||||
|
||||
Vector3 IAstarAI.desiredVelocity {
|
||||
get {
|
||||
// The AILerp script sets the position every frame. It does not take into account physics
|
||||
// or other things. So the velocity should always be the same as the desired velocity.
|
||||
return (this as IAstarAI).velocity;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>\copydoc Pathfinding::IAstarAI::steeringTarget</summary>
|
||||
Vector3 IAstarAI.steeringTarget {
|
||||
get {
|
||||
// AILerp doesn't use steering at all, so we will just return a point ahead of the agent in the direction it is moving.
|
||||
return interpolator.valid ? interpolator.position + interpolator.tangent : simulatedPosition;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>\copydoc Pathfinding::IAstarAI::remainingDistance</summary>
|
||||
public float remainingDistance {
|
||||
get {
|
||||
return Mathf.Max(interpolator.remainingDistance, 0);
|
||||
}
|
||||
set {
|
||||
interpolator.remainingDistance = Mathf.Max(value, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>\copydoc Pathfinding::IAstarAI::hasPath</summary>
|
||||
public bool hasPath {
|
||||
get {
|
||||
return interpolator.valid;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>\copydoc Pathfinding::IAstarAI::pathPending</summary>
|
||||
public bool pathPending {
|
||||
get {
|
||||
return !canSearchAgain;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>\copydoc Pathfinding::IAstarAI::isStopped</summary>
|
||||
public bool isStopped { get; set; }
|
||||
|
||||
/// <summary>\copydoc Pathfinding::IAstarAI::onSearchPath</summary>
|
||||
public System.Action onSearchPath { get; set; }
|
||||
|
||||
/// <summary>Cached Seeker component</summary>
|
||||
protected Seeker seeker;
|
||||
|
||||
/// <summary>Cached Transform component</summary>
|
||||
protected Transform tr;
|
||||
|
||||
/// <summary>Current path which is followed</summary>
|
||||
protected ABPath path;
|
||||
|
||||
/// <summary>Only when the previous path has been returned should a search for a new path be done</summary>
|
||||
protected bool canSearchAgain = true;
|
||||
|
||||
/// <summary>
|
||||
/// When a new path was returned, the AI was moving along this ray.
|
||||
/// Used to smoothly interpolate between the previous movement and the movement along the new path.
|
||||
/// The speed is equal to movement direction.
|
||||
/// </summary>
|
||||
protected Vector3 previousMovementOrigin;
|
||||
protected Vector3 previousMovementDirection;
|
||||
|
||||
/// <summary>
|
||||
/// Time since the path was replaced by a new path.
|
||||
/// See: <see cref="interpolatePathSwitches"/>
|
||||
/// </summary>
|
||||
protected float pathSwitchInterpolationTime = 0;
|
||||
|
||||
protected PathInterpolator interpolator = new PathInterpolator();
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Holds if the Start function has been run.
|
||||
/// Used to test if coroutines should be started in OnEnable to prevent calculating paths
|
||||
/// in the awake stage (or rather before start on frame 0).
|
||||
/// </summary>
|
||||
bool startHasRun = false;
|
||||
|
||||
Vector3 previousPosition1, previousPosition2, simulatedPosition;
|
||||
Quaternion simulatedRotation;
|
||||
|
||||
/// <summary>Required for serialization backward compatibility</summary>
|
||||
[UnityEngine.Serialization.FormerlySerializedAs("target")][SerializeField][HideInInspector]
|
||||
Transform targetCompatibility;
|
||||
|
||||
[SerializeField]
|
||||
[HideInInspector]
|
||||
[UnityEngine.Serialization.FormerlySerializedAs("repathRate")]
|
||||
float repathRateCompatibility = float.NaN;
|
||||
|
||||
[SerializeField]
|
||||
[HideInInspector]
|
||||
[UnityEngine.Serialization.FormerlySerializedAs("canSearch")]
|
||||
bool canSearchCompability = false;
|
||||
|
||||
protected AILerp () {
|
||||
// Note that this needs to be set here in the constructor and not in e.g Awake
|
||||
// because it is possible that other code runs and sets the destination property
|
||||
// before the Awake method on this script runs.
|
||||
destination = new Vector3(float.PositiveInfinity, float.PositiveInfinity, float.PositiveInfinity);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes reference variables.
|
||||
/// If you override this function you should in most cases call base.Awake () at the start of it.
|
||||
/// </summary>
|
||||
protected override void Awake () {
|
||||
base.Awake();
|
||||
//This is a simple optimization, cache the transform component lookup
|
||||
tr = transform;
|
||||
|
||||
seeker = GetComponent<Seeker>();
|
||||
|
||||
// Tell the StartEndModifier to ask for our exact position when post processing the path This
|
||||
// is important if we are using prediction and requesting a path from some point slightly ahead
|
||||
// of us since then the start point in the path request may be far from our position when the
|
||||
// path has been calculated. This is also good because if a long path is requested, it may take
|
||||
// a few frames for it to be calculated so we could have moved some distance during that time
|
||||
seeker.startEndModifier.adjustStartPoint = () => simulatedPosition;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Starts searching for paths.
|
||||
/// If you override this function you should in most cases call base.Start () at the start of it.
|
||||
/// See: <see cref="Init"/>
|
||||
/// See: <see cref="RepeatTrySearchPath"/>
|
||||
/// </summary>
|
||||
protected virtual void Start () {
|
||||
startHasRun = true;
|
||||
Init();
|
||||
}
|
||||
|
||||
/// <summary>Called when the component is enabled</summary>
|
||||
protected virtual void OnEnable () {
|
||||
// Make sure we receive callbacks when paths complete
|
||||
seeker.pathCallback += OnPathComplete;
|
||||
Init();
|
||||
}
|
||||
|
||||
void Init () {
|
||||
if (startHasRun) {
|
||||
// The Teleport call will make sure some variables are properly initialized (like #prevPosition1 and #prevPosition2)
|
||||
Teleport(position, false);
|
||||
autoRepath.Reset();
|
||||
if (shouldRecalculatePath) SearchPath();
|
||||
}
|
||||
}
|
||||
|
||||
public void OnDisable () {
|
||||
ClearPath();
|
||||
// Make sure we no longer receive callbacks when paths complete
|
||||
seeker.pathCallback -= OnPathComplete;
|
||||
}
|
||||
|
||||
/// <summary>\copydoc Pathfinding::IAstarAI::GetRemainingPath</summary>
|
||||
public void GetRemainingPath (List<Vector3> buffer, out bool stale) {
|
||||
buffer.Clear();
|
||||
if (!interpolator.valid) {
|
||||
buffer.Add(position);
|
||||
stale = true;
|
||||
return;
|
||||
}
|
||||
|
||||
stale = false;
|
||||
interpolator.GetRemainingPath(buffer);
|
||||
// The agent is almost always at interpolation.position (which is buffer[0])
|
||||
// but sometimes - in particular when interpolating between two paths - the agent might at a slightly different position.
|
||||
// So we replace the first point with the actual position of the agent.
|
||||
buffer[0] = position;
|
||||
}
|
||||
|
||||
public void Teleport (Vector3 position, bool clearPath = true) {
|
||||
if (clearPath) ClearPath();
|
||||
simulatedPosition = previousPosition1 = previousPosition2 = position;
|
||||
if (updatePosition) tr.position = position;
|
||||
reachedEndOfPath = false;
|
||||
if (clearPath) SearchPath();
|
||||
}
|
||||
|
||||
/// <summary>True if the path should be automatically recalculated as soon as possible</summary>
|
||||
protected virtual bool shouldRecalculatePath {
|
||||
get {
|
||||
return canSearchAgain && autoRepath.ShouldRecalculatePath(position, 0.0f, destination);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Requests a path to the target.
|
||||
/// Deprecated: Use <see cref="SearchPath"/> instead.
|
||||
/// </summary>
|
||||
[System.Obsolete("Use SearchPath instead")]
|
||||
public virtual void ForceSearchPath () {
|
||||
SearchPath();
|
||||
}
|
||||
|
||||
/// <summary>Requests a path to the target.</summary>
|
||||
public virtual void SearchPath () {
|
||||
if (float.IsPositiveInfinity(destination.x)) return;
|
||||
if (onSearchPath != null) onSearchPath();
|
||||
|
||||
// This is where the path should start to search from
|
||||
var currentPosition = GetFeetPosition();
|
||||
|
||||
// If we are following a path, start searching from the node we will
|
||||
// reach next this can prevent odd turns right at the start of the path
|
||||
/*if (interpolator.valid) {
|
||||
var prevDist = interpolator.distance;
|
||||
// Move to the end of the current segment
|
||||
interpolator.MoveToSegment(interpolator.segmentIndex, 1);
|
||||
currentPosition = interpolator.position;
|
||||
// Move back to the original position
|
||||
interpolator.distance = prevDist;
|
||||
}*/
|
||||
|
||||
canSearchAgain = false;
|
||||
|
||||
// Create a new path request
|
||||
// The OnPathComplete method will later be called with the result
|
||||
SetPath(ABPath.Construct(currentPosition, destination, null), false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The end of the path has been reached.
|
||||
/// If you want custom logic for when the AI has reached it's destination
|
||||
/// add it here.
|
||||
/// You can also create a new script which inherits from this one
|
||||
/// and override the function in that script.
|
||||
/// </summary>
|
||||
public virtual void OnTargetReached () {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when a requested path has finished calculation.
|
||||
/// A path is first requested by <see cref="SearchPath"/>, it is then calculated, probably in the same or the next frame.
|
||||
/// Finally it is returned to the seeker which forwards it to this function.
|
||||
/// </summary>
|
||||
protected virtual void OnPathComplete (Path _p) {
|
||||
ABPath p = _p as ABPath;
|
||||
|
||||
if (p == null) throw new System.Exception("This function only handles ABPaths, do not use special path types");
|
||||
|
||||
canSearchAgain = true;
|
||||
|
||||
// Increase the reference count on the path.
|
||||
// This is used for path pooling
|
||||
p.Claim(this);
|
||||
|
||||
// Path couldn't be calculated of some reason.
|
||||
// More info in p.errorLog (debug string)
|
||||
if (p.error) {
|
||||
p.Release(this);
|
||||
return;
|
||||
}
|
||||
|
||||
if (interpolatePathSwitches) {
|
||||
ConfigurePathSwitchInterpolation();
|
||||
}
|
||||
|
||||
|
||||
// Replace the old path
|
||||
var oldPath = path;
|
||||
path = p;
|
||||
reachedEndOfPath = false;
|
||||
|
||||
// The RandomPath and MultiTargetPath do not have a well defined destination that could have been
|
||||
// set before the paths were calculated. So we instead set the destination here so that some properties
|
||||
// like #reachedDestination and #remainingDistance work correctly.
|
||||
if (path is RandomPath rpath) {
|
||||
destination = rpath.originalEndPoint;
|
||||
} else if (path is MultiTargetPath mpath) {
|
||||
destination = mpath.originalEndPoint;
|
||||
}
|
||||
|
||||
// Just for the rest of the code to work, if there
|
||||
// is only one waypoint in the path add another one
|
||||
if (path.vectorPath != null && path.vectorPath.Count == 1) {
|
||||
path.vectorPath.Insert(0, GetFeetPosition());
|
||||
}
|
||||
|
||||
// Reset some variables
|
||||
ConfigureNewPath();
|
||||
|
||||
// Release the previous path
|
||||
// This is used for path pooling.
|
||||
// This is done after the interpolator has been configured in the ConfigureNewPath method
|
||||
// as this method would otherwise invalidate the interpolator
|
||||
// since the vectorPath list (which the interpolator uses) will be pooled.
|
||||
if (oldPath != null) oldPath.Release(this);
|
||||
|
||||
if (interpolator.remainingDistance < 0.0001f && !reachedEndOfPath) {
|
||||
reachedEndOfPath = true;
|
||||
OnTargetReached();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clears the current path of the agent.
|
||||
///
|
||||
/// Usually invoked using <see cref="SetPath(null)"/>
|
||||
///
|
||||
/// See: <see cref="SetPath"/>
|
||||
/// See: <see cref="isStopped"/>
|
||||
/// </summary>
|
||||
protected virtual void ClearPath () {
|
||||
// Abort any calculations in progress
|
||||
if (seeker != null) seeker.CancelCurrentPathRequest();
|
||||
canSearchAgain = true;
|
||||
reachedEndOfPath = false;
|
||||
|
||||
// Release current path so that it can be pooled
|
||||
if (path != null) path.Release(this);
|
||||
path = null;
|
||||
interpolator.SetPath(null);
|
||||
}
|
||||
|
||||
/// <summary>\copydoc Pathfinding::IAstarAI::SetPath</summary>
|
||||
public void SetPath (Path path, bool updateDestinationFromPath = true) {
|
||||
if (updateDestinationFromPath && path is ABPath abPath && !(path is RandomPath)) {
|
||||
this.destination = abPath.originalEndPoint;
|
||||
}
|
||||
|
||||
if (path == null) {
|
||||
ClearPath();
|
||||
} else if (path.PipelineState == PathState.Created) {
|
||||
// Path has not started calculation yet
|
||||
canSearchAgain = false;
|
||||
seeker.CancelCurrentPathRequest();
|
||||
seeker.StartPath(path);
|
||||
autoRepath.DidRecalculatePath(destination);
|
||||
} else if (path.PipelineState == PathState.Returned) {
|
||||
// Path has already been calculated
|
||||
|
||||
// We might be calculating another path at the same time, and we don't want that path to override this one. So cancel it.
|
||||
if (seeker.GetCurrentPath() != path) seeker.CancelCurrentPathRequest();
|
||||
else throw new System.ArgumentException("If you calculate the path using seeker.StartPath then this script will pick up the calculated path anyway as it listens for all paths the Seeker finishes calculating. You should not call SetPath in that case.");
|
||||
|
||||
OnPathComplete(path);
|
||||
} else {
|
||||
// Path calculation has been started, but it is not yet complete. Cannot really handle this.
|
||||
throw new System.ArgumentException("You must call the SetPath method with a path that either has been completely calculated or one whose path calculation has not been started at all. It looks like the path calculation for the path you tried to use has been started, but is not yet finished.");
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void ConfigurePathSwitchInterpolation () {
|
||||
bool reachedEndOfPreviousPath = interpolator.valid && interpolator.remainingDistance < 0.0001f;
|
||||
|
||||
if (interpolator.valid && !reachedEndOfPreviousPath) {
|
||||
previousMovementOrigin = interpolator.position;
|
||||
previousMovementDirection = interpolator.tangent.normalized * interpolator.remainingDistance;
|
||||
pathSwitchInterpolationTime = 0;
|
||||
} else {
|
||||
previousMovementOrigin = Vector3.zero;
|
||||
previousMovementDirection = Vector3.zero;
|
||||
pathSwitchInterpolationTime = float.PositiveInfinity;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual Vector3 GetFeetPosition () {
|
||||
return position;
|
||||
}
|
||||
|
||||
/// <summary>Finds the closest point on the current path and configures the <see cref="interpolator"/></summary>
|
||||
protected virtual void ConfigureNewPath () {
|
||||
var hadValidPath = interpolator.valid;
|
||||
var prevTangent = hadValidPath ? interpolator.tangent : Vector3.zero;
|
||||
|
||||
interpolator.SetPath(path.vectorPath);
|
||||
interpolator.MoveToClosestPoint(GetFeetPosition());
|
||||
|
||||
if (interpolatePathSwitches && switchPathInterpolationSpeed > 0.01f && hadValidPath) {
|
||||
var correctionFactor = Mathf.Max(-Vector3.Dot(prevTangent.normalized, interpolator.tangent.normalized), 0);
|
||||
interpolator.distance -= speed*correctionFactor*(1f/switchPathInterpolationSpeed);
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void Update () {
|
||||
if (shouldRecalculatePath) SearchPath();
|
||||
if (canMove) {
|
||||
Vector3 nextPosition;
|
||||
Quaternion nextRotation;
|
||||
MovementUpdate(Time.deltaTime, out nextPosition, out nextRotation);
|
||||
FinalizeMovement(nextPosition, nextRotation);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>\copydoc Pathfinding::IAstarAI::MovementUpdate</summary>
|
||||
public void MovementUpdate (float deltaTime, out Vector3 nextPosition, out Quaternion nextRotation) {
|
||||
if (updatePosition) simulatedPosition = tr.position;
|
||||
if (updateRotation) simulatedRotation = tr.rotation;
|
||||
|
||||
Vector3 direction;
|
||||
|
||||
nextPosition = CalculateNextPosition(out direction, isStopped ? 0f : deltaTime);
|
||||
|
||||
if (enableRotation) nextRotation = SimulateRotationTowards(direction, deltaTime);
|
||||
else nextRotation = simulatedRotation;
|
||||
}
|
||||
|
||||
/// <summary>\copydoc Pathfinding::IAstarAI::FinalizeMovement</summary>
|
||||
public void FinalizeMovement (Vector3 nextPosition, Quaternion nextRotation) {
|
||||
previousPosition2 = previousPosition1;
|
||||
previousPosition1 = simulatedPosition = nextPosition;
|
||||
simulatedRotation = nextRotation;
|
||||
if (updatePosition) tr.position = nextPosition;
|
||||
if (updateRotation) tr.rotation = nextRotation;
|
||||
}
|
||||
|
||||
Quaternion SimulateRotationTowards (Vector3 direction, float deltaTime) {
|
||||
// Rotate unless we are really close to the target
|
||||
if (direction != Vector3.zero) {
|
||||
Quaternion targetRotation = Quaternion.LookRotation(direction, orientation == OrientationMode.YAxisForward ? Vector3.back : Vector3.up);
|
||||
// This causes the character to only rotate around the Z axis
|
||||
if (orientation == OrientationMode.YAxisForward) targetRotation *= Quaternion.Euler(90, 0, 0);
|
||||
return Quaternion.Slerp(simulatedRotation, targetRotation, deltaTime * rotationSpeed);
|
||||
}
|
||||
return simulatedRotation;
|
||||
}
|
||||
|
||||
/// <summary>Calculate the AI's next position (one frame in the future).</summary>
|
||||
/// <param name="direction">The tangent of the segment the AI is currently traversing. Not normalized.</param>
|
||||
protected virtual Vector3 CalculateNextPosition (out Vector3 direction, float deltaTime) {
|
||||
if (!interpolator.valid) {
|
||||
direction = Vector3.zero;
|
||||
return simulatedPosition;
|
||||
}
|
||||
|
||||
interpolator.distance += deltaTime * speed;
|
||||
|
||||
if (interpolator.remainingDistance < 0.0001f && !reachedEndOfPath) {
|
||||
reachedEndOfPath = true;
|
||||
OnTargetReached();
|
||||
}
|
||||
|
||||
direction = interpolator.tangent;
|
||||
pathSwitchInterpolationTime += deltaTime;
|
||||
var alpha = switchPathInterpolationSpeed * pathSwitchInterpolationTime;
|
||||
if (interpolatePathSwitches && alpha < 1f) {
|
||||
// Find the approximate position we would be at if we
|
||||
// would have continued to follow the previous path
|
||||
Vector3 positionAlongPreviousPath = previousMovementOrigin + Vector3.ClampMagnitude(previousMovementDirection, speed * pathSwitchInterpolationTime);
|
||||
|
||||
// Interpolate between the position on the current path and the position
|
||||
// we would have had if we would have continued along the previous path.
|
||||
return Vector3.Lerp(positionAlongPreviousPath, interpolator.position, alpha);
|
||||
} else {
|
||||
return interpolator.position;
|
||||
}
|
||||
}
|
||||
|
||||
protected override int OnUpgradeSerializedData (int version, bool unityThread) {
|
||||
#pragma warning disable 618
|
||||
if (unityThread && targetCompatibility != null) target = targetCompatibility;
|
||||
#pragma warning restore 618
|
||||
|
||||
if (version <= 3) {
|
||||
repathRate = repathRateCompatibility;
|
||||
canSearch = canSearchCompability;
|
||||
}
|
||||
return 4;
|
||||
}
|
||||
|
||||
public virtual void OnDrawGizmos () {
|
||||
tr = transform;
|
||||
autoRepath.DrawGizmos(this.position, 0.0f);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 847a14d4dc9cc43679ab34fc78e0182f
|
||||
timeCreated: 1454879612
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
531
BlueWater/Assets/AstarPathfindingProject/Core/AI/AIPath.cs
Normal file
531
BlueWater/Assets/AstarPathfindingProject/Core/AI/AIPath.cs
Normal file
@ -0,0 +1,531 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Pathfinding {
|
||||
using Pathfinding.RVO;
|
||||
using Pathfinding.Util;
|
||||
|
||||
/// <summary>
|
||||
/// AI for following paths.
|
||||
///
|
||||
/// [Open online documentation to see images]
|
||||
///
|
||||
/// This AI is the default movement script which comes with the A* Pathfinding Project.
|
||||
/// It is in no way required by the rest of the system, so feel free to write your own. But I hope this script will make it easier
|
||||
/// to set up movement for the characters in your game.
|
||||
/// This script works well for many types of units, but if you need the highest performance (for example if you are moving hundreds of characters) you
|
||||
/// may want to customize this script or write a custom movement script to be able to optimize it specifically for your game.
|
||||
///
|
||||
/// This script will try to move to a given <see cref="destination"/>. At <see cref="repathRate regular"/>, the path to the destination will be recalculated.
|
||||
/// If you want to make the AI to follow a particular object you can attach the <see cref="Pathfinding.AIDestinationSetter"/> component.
|
||||
/// Take a look at the getstarted (view in online documentation for working links) tutorial for more instructions on how to configure this script.
|
||||
///
|
||||
/// Here is a video of this script being used move an agent around (technically it uses the <see cref="Pathfinding.Examples.MineBotAI"/> script that inherits from this one but adds a bit of animation support for the example scenes):
|
||||
/// [Open online documentation to see videos]
|
||||
///
|
||||
/// \section variables Quick overview of the variables
|
||||
/// In the inspector in Unity, you will see a bunch of variables. You can view detailed information further down, but here's a quick overview.
|
||||
///
|
||||
/// The <see cref="repathRate"/> determines how often it will search for new paths, if you have fast moving targets, you might want to set it to a lower value.
|
||||
/// The <see cref="destination"/> field is where the AI will try to move, it can be a point on the ground where the player has clicked in an RTS for example.
|
||||
/// Or it can be the player object in a zombie game.
|
||||
/// The <see cref="maxSpeed"/> is self-explanatory, as is <see cref="rotationSpeed"/>. however <see cref="slowdownDistance"/> might require some explanation:
|
||||
/// It is the approximate distance from the target where the AI will start to slow down. Setting it to a large value will make the AI slow down very gradually.
|
||||
/// <see cref="pickNextWaypointDist"/> determines the distance to the point the AI will move to (see image below).
|
||||
///
|
||||
/// Below is an image illustrating several variables that are exposed by this class (<see cref="pickNextWaypointDist"/>, <see cref="steeringTarget"/>, <see cref="desiredVelocity)"/>
|
||||
/// [Open online documentation to see images]
|
||||
///
|
||||
/// This script has many movement fallbacks.
|
||||
/// If it finds an RVOController attached to the same GameObject as this component, it will use that. If it finds a character controller it will also use that.
|
||||
/// If it finds a rigidbody it will use that. Lastly it will fall back to simply modifying Transform.position which is guaranteed to always work and is also the most performant option.
|
||||
///
|
||||
/// \section how-aipath-works How it works
|
||||
/// In this section I'm going to go over how this script is structured and how information flows.
|
||||
/// This is useful if you want to make changes to this script or if you just want to understand how it works a bit more deeply.
|
||||
/// However you do not need to read this section if you are just going to use the script as-is.
|
||||
///
|
||||
/// This script inherits from the <see cref="AIBase"/> class. The movement happens either in Unity's standard <see cref="Update"/> or <see cref="FixedUpdate"/> method.
|
||||
/// They are both defined in the AIBase class. Which one is actually used depends on if a rigidbody is used for movement or not.
|
||||
/// Rigidbody movement has to be done inside the FixedUpdate method while otherwise it is better to do it in Update.
|
||||
///
|
||||
/// From there a call is made to the <see cref="MovementUpdate"/> method (which in turn calls <see cref="MovementUpdateInternal)"/>.
|
||||
/// This method contains the main bulk of the code and calculates how the AI *wants* to move. However it doesn't do any movement itself.
|
||||
/// Instead it returns the position and rotation it wants the AI to move to have at the end of the frame.
|
||||
/// The <see cref="Update"/> (or <see cref="FixedUpdate)"/> method then passes these values to the <see cref="FinalizeMovement"/> method which is responsible for actually moving the character.
|
||||
/// That method also handles things like making sure the AI doesn't fall through the ground using raycasting.
|
||||
///
|
||||
/// The AI recalculates its path regularly. This happens in the Update method which checks <see cref="shouldRecalculatePath"/> and if that returns true it will call <see cref="SearchPath"/>.
|
||||
/// The <see cref="SearchPath"/> method will prepare a path request and send it to the <see cref="Pathfinding.Seeker"/> component which should be attached to the same GameObject as this script.
|
||||
/// Since this script will when waking up register to the <see cref="Pathfinding.Seeker.pathCallback"/> delegate this script will be notified every time a new path is calculated by the <see cref="OnPathComplete"/> method being called.
|
||||
/// It may take one or sometimes multiple frames for the path to be calculated, but finally the <see cref="OnPathComplete"/> method will be called and the current path that the AI is following will be replaced.
|
||||
/// </summary>
|
||||
[AddComponentMenu("Pathfinding/AI/AIPath (2D,3D)")]
|
||||
public partial class AIPath : AIBase, IAstarAI {
|
||||
/// <summary>
|
||||
/// How quickly the agent accelerates.
|
||||
/// Positive values represent an acceleration in world units per second squared.
|
||||
/// Negative values are interpreted as an inverse time of how long it should take for the agent to reach its max speed.
|
||||
/// For example if it should take roughly 0.4 seconds for the agent to reach its max speed then this field should be set to -1/0.4 = -2.5.
|
||||
/// For a negative value the final acceleration will be: -acceleration*maxSpeed.
|
||||
/// This behaviour exists mostly for compatibility reasons.
|
||||
///
|
||||
/// In the Unity inspector there are two modes: Default and Custom. In the Default mode this field is set to -2.5 which means that it takes about 0.4 seconds for the agent to reach its top speed.
|
||||
/// In the Custom mode you can set the acceleration to any positive value.
|
||||
/// </summary>
|
||||
public float maxAcceleration = -2.5f;
|
||||
|
||||
/// <summary>
|
||||
/// Rotation speed in degrees per second.
|
||||
/// Rotation is calculated using Quaternion.RotateTowards. This variable represents the rotation speed in degrees per second.
|
||||
/// The higher it is, the faster the character will be able to rotate.
|
||||
/// </summary>
|
||||
[UnityEngine.Serialization.FormerlySerializedAs("turningSpeed")]
|
||||
public float rotationSpeed = 360;
|
||||
|
||||
/// <summary>Distance from the end of the path where the AI will start to slow down</summary>
|
||||
public float slowdownDistance = 0.6F;
|
||||
|
||||
/// <summary>
|
||||
/// How far the AI looks ahead along the path to determine the point it moves to.
|
||||
/// In world units.
|
||||
/// If you enable the <see cref="alwaysDrawGizmos"/> toggle this value will be visualized in the scene view as a blue circle around the agent.
|
||||
/// [Open online documentation to see images]
|
||||
///
|
||||
/// Here are a few example videos showing some typical outcomes with good values as well as how it looks when this value is too low and too high.
|
||||
/// <table>
|
||||
/// <tr><td>[Open online documentation to see videos]</td><td>\xmlonly <verbatim><span class="label label-danger">Too low</span><br/></verbatim>\endxmlonly A too low value and a too low acceleration will result in the agent overshooting a lot and not managing to follow the path well.</td></tr>
|
||||
/// <tr><td>[Open online documentation to see videos]</td><td>\xmlonly <verbatim><span class="label label-warning">Ok</span><br/></verbatim>\endxmlonly A low value but a high acceleration works decently to make the AI follow the path more closely. Note that the <see cref="Pathfinding.AILerp"/> component is better suited if you want the agent to follow the path without any deviations.</td></tr>
|
||||
/// <tr><td>[Open online documentation to see videos]</td><td>\xmlonly <verbatim><span class="label label-success">Ok</span><br/></verbatim>\endxmlonly A reasonable value in this example.</td></tr>
|
||||
/// <tr><td>[Open online documentation to see videos]</td><td>\xmlonly <verbatim><span class="label label-success">Ok</span><br/></verbatim>\endxmlonly A reasonable value in this example, but the path is followed slightly more loosely than in the previous video.</td></tr>
|
||||
/// <tr><td>[Open online documentation to see videos]</td><td>\xmlonly <verbatim><span class="label label-danger">Too high</span><br/></verbatim>\endxmlonly A too high value will make the agent follow the path too loosely and may cause it to try to move through obstacles.</td></tr>
|
||||
/// </table>
|
||||
/// </summary>
|
||||
public float pickNextWaypointDist = 2;
|
||||
|
||||
/// <summary>
|
||||
/// Distance to the end point to consider the end of path to be reached.
|
||||
/// When the end is within this distance then <see cref="OnTargetReached"/> will be called and <see cref="reachedEndOfPath"/> will return true.
|
||||
/// </summary>
|
||||
public float endReachedDistance = 0.2F;
|
||||
|
||||
/// <summary>Draws detailed gizmos constantly in the scene view instead of only when the agent is selected and settings are being modified</summary>
|
||||
public bool alwaysDrawGizmos;
|
||||
|
||||
/// <summary>
|
||||
/// Slow down when not facing the target direction.
|
||||
/// Incurs at a small performance overhead.
|
||||
/// </summary>
|
||||
public bool slowWhenNotFacingTarget = true;
|
||||
|
||||
/// <summary>
|
||||
/// What to do when within <see cref="endReachedDistance"/> units from the destination.
|
||||
/// The character can either stop immediately when it comes within that distance, which is useful for e.g archers
|
||||
/// or other ranged units that want to fire on a target. Or the character can continue to try to reach the exact
|
||||
/// destination point and come to a full stop there. This is useful if you want the character to reach the exact
|
||||
/// point that you specified.
|
||||
///
|
||||
/// Note: <see cref="reachedEndOfPath"/> will become true when the character is within <see cref="endReachedDistance"/> units from the destination
|
||||
/// regardless of what this field is set to.
|
||||
/// </summary>
|
||||
public CloseToDestinationMode whenCloseToDestination = CloseToDestinationMode.Stop;
|
||||
|
||||
/// <summary>
|
||||
/// Ensure that the character is always on the traversable surface of the navmesh.
|
||||
/// When this option is enabled a <see cref="AstarPath.GetNearest"/> query will be done every frame to find the closest node that the agent can walk on
|
||||
/// and if the agent is not inside that node, then the agent will be moved to it.
|
||||
///
|
||||
/// This is especially useful together with local avoidance in order to avoid agents pushing each other into walls.
|
||||
/// See: local-avoidance (view in online documentation for working links) for more info about this.
|
||||
///
|
||||
/// This option also integrates with local avoidance so that if the agent is say forced into a wall by other agents the local avoidance
|
||||
/// system will be informed about that wall and can take that into account.
|
||||
///
|
||||
/// Enabling this has some performance impact depending on the graph type (pretty fast for grid graphs, slightly slower for navmesh/recast graphs).
|
||||
/// If you are using a navmesh/recast graph you may want to switch to the <see cref="Pathfinding.RichAI"/> movement script which is specifically written for navmesh/recast graphs and
|
||||
/// does this kind of clamping out of the box. In many cases it can also follow the path more smoothly around sharp bends in the path.
|
||||
///
|
||||
/// It is not recommended that you use this option together with the funnel modifier on grid graphs because the funnel modifier will make the path
|
||||
/// go very close to the border of the graph and this script has a tendency to try to cut corners a bit. This may cause it to try to go slightly outside the
|
||||
/// traversable surface near corners and that will look bad if this option is enabled.
|
||||
///
|
||||
/// Warning: This option makes no sense to use on point graphs because point graphs do not have a surface.
|
||||
/// Enabling this option when using a point graph will lead to the agent being snapped to the closest node every frame which is likely not what you want.
|
||||
///
|
||||
/// Below you can see an image where several agents using local avoidance were ordered to go to the same point in a corner.
|
||||
/// When not constraining the agents to the graph they are easily pushed inside obstacles.
|
||||
/// [Open online documentation to see images]
|
||||
/// </summary>
|
||||
public bool constrainInsideGraph = false;
|
||||
|
||||
/// <summary>Current path which is followed</summary>
|
||||
protected Path path;
|
||||
|
||||
/// <summary>Helper which calculates points along the current path</summary>
|
||||
protected PathInterpolator interpolator = new PathInterpolator();
|
||||
|
||||
#region IAstarAI implementation
|
||||
|
||||
/// <summary>\copydoc Pathfinding::IAstarAI::Teleport</summary>
|
||||
public override void Teleport (Vector3 newPosition, bool clearPath = true) {
|
||||
reachedEndOfPath = false;
|
||||
base.Teleport(newPosition, clearPath);
|
||||
}
|
||||
|
||||
/// <summary>\copydoc Pathfinding::IAstarAI::remainingDistance</summary>
|
||||
public float remainingDistance {
|
||||
get {
|
||||
return interpolator.valid ? interpolator.remainingDistance + movementPlane.ToPlane(interpolator.position - position).magnitude : float.PositiveInfinity;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>\copydoc Pathfinding::IAstarAI::reachedDestination</summary>
|
||||
public bool reachedDestination {
|
||||
get {
|
||||
if (!reachedEndOfPath) return false;
|
||||
if (!interpolator.valid || remainingDistance + movementPlane.ToPlane(destination - interpolator.endPoint).magnitude > endReachedDistance) return false;
|
||||
|
||||
// Don't do height checks in 2D mode
|
||||
if (orientation != OrientationMode.YAxisForward) {
|
||||
// Check if the destination is above the head of the character or far below the feet of it
|
||||
float yDifference;
|
||||
movementPlane.ToPlane(destination - position, out yDifference);
|
||||
var h = tr.localScale.y * height;
|
||||
if (yDifference > h || yDifference < -h*0.5) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>\copydoc Pathfinding::IAstarAI::reachedEndOfPath</summary>
|
||||
public bool reachedEndOfPath { get; protected set; }
|
||||
|
||||
/// <summary>\copydoc Pathfinding::IAstarAI::hasPath</summary>
|
||||
public bool hasPath {
|
||||
get {
|
||||
return interpolator.valid;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>\copydoc Pathfinding::IAstarAI::pathPending</summary>
|
||||
public bool pathPending {
|
||||
get {
|
||||
return waitingForPathCalculation;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>\copydoc Pathfinding::IAstarAI::steeringTarget</summary>
|
||||
public Vector3 steeringTarget {
|
||||
get {
|
||||
return interpolator.valid ? interpolator.position : position;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>\copydoc Pathfinding::IAstarAI::radius</summary>
|
||||
float IAstarAI.radius { get { return radius; } set { radius = value; } }
|
||||
|
||||
/// <summary>\copydoc Pathfinding::IAstarAI::height</summary>
|
||||
float IAstarAI.height { get { return height; } set { height = value; } }
|
||||
|
||||
/// <summary>\copydoc Pathfinding::IAstarAI::maxSpeed</summary>
|
||||
float IAstarAI.maxSpeed { get { return maxSpeed; } set { maxSpeed = value; } }
|
||||
|
||||
/// <summary>\copydoc Pathfinding::IAstarAI::canSearch</summary>
|
||||
bool IAstarAI.canSearch { get { return canSearch; } set { canSearch = value; } }
|
||||
|
||||
/// <summary>\copydoc Pathfinding::IAstarAI::canMove</summary>
|
||||
bool IAstarAI.canMove { get { return canMove; } set { canMove = value; } }
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>\copydoc Pathfinding::IAstarAI::GetRemainingPath</summary>
|
||||
public void GetRemainingPath (List<Vector3> buffer, out bool stale) {
|
||||
buffer.Clear();
|
||||
buffer.Add(position);
|
||||
if (!interpolator.valid) {
|
||||
stale = true;
|
||||
return;
|
||||
}
|
||||
|
||||
stale = false;
|
||||
interpolator.GetRemainingPath(buffer);
|
||||
}
|
||||
|
||||
protected override void OnDisable () {
|
||||
base.OnDisable();
|
||||
|
||||
// Release current path so that it can be pooled
|
||||
if (path != null) path.Release(this);
|
||||
path = null;
|
||||
interpolator.SetPath(null);
|
||||
reachedEndOfPath = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The end of the path has been reached.
|
||||
/// If you want custom logic for when the AI has reached it's destination add it here. You can
|
||||
/// also create a new script which inherits from this one and override the function in that script.
|
||||
///
|
||||
/// This method will be called again if a new path is calculated as the destination may have changed.
|
||||
/// So when the agent is close to the destination this method will typically be called every <see cref="repathRate"/> seconds.
|
||||
/// </summary>
|
||||
public virtual void OnTargetReached () {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when a requested path has been calculated.
|
||||
/// A path is first requested by <see cref="UpdatePath"/>, it is then calculated, probably in the same or the next frame.
|
||||
/// Finally it is returned to the seeker which forwards it to this function.
|
||||
/// </summary>
|
||||
protected override void OnPathComplete (Path newPath) {
|
||||
ABPath p = newPath as ABPath;
|
||||
|
||||
if (p == null) throw new System.Exception("This function only handles ABPaths, do not use special path types");
|
||||
|
||||
waitingForPathCalculation = false;
|
||||
|
||||
// Increase the reference count on the new path.
|
||||
// This is used for object pooling to reduce allocations.
|
||||
p.Claim(this);
|
||||
|
||||
// Path couldn't be calculated of some reason.
|
||||
// More info in p.errorLog (debug string)
|
||||
if (p.error) {
|
||||
p.Release(this);
|
||||
SetPath(null);
|
||||
return;
|
||||
}
|
||||
|
||||
// Release the previous path.
|
||||
if (path != null) path.Release(this);
|
||||
|
||||
// Replace the old path
|
||||
path = p;
|
||||
|
||||
// The RandomPath and MultiTargetPath do not have a well defined destination that could have been
|
||||
// set before the paths were calculated. So we instead set the destination here so that some properties
|
||||
// like #reachedDestination and #remainingDistance work correctly.
|
||||
if (path is RandomPath rpath) {
|
||||
destination = rpath.originalEndPoint;
|
||||
} else if (path is MultiTargetPath mpath) {
|
||||
destination = mpath.originalEndPoint;
|
||||
}
|
||||
|
||||
// Make sure the path contains at least 2 points
|
||||
if (path.vectorPath.Count == 1) path.vectorPath.Add(path.vectorPath[0]);
|
||||
interpolator.SetPath(path.vectorPath);
|
||||
|
||||
var graph = path.path.Count > 0 ? AstarData.GetGraph(path.path[0]) as ITransformedGraph : null;
|
||||
movementPlane = graph != null ? graph.transform : (orientation == OrientationMode.YAxisForward ? new GraphTransform(Matrix4x4.TRS(Vector3.zero, Quaternion.Euler(-90, 270, 90), Vector3.one)) : GraphTransform.identityTransform);
|
||||
|
||||
// Reset some variables
|
||||
reachedEndOfPath = false;
|
||||
|
||||
// Simulate movement from the point where the path was requested
|
||||
// to where we are right now. This reduces the risk that the agent
|
||||
// gets confused because the first point in the path is far away
|
||||
// from the current position (possibly behind it which could cause
|
||||
// the agent to turn around, and that looks pretty bad).
|
||||
interpolator.MoveToLocallyClosestPoint((GetFeetPosition() + p.originalStartPoint) * 0.5f);
|
||||
interpolator.MoveToLocallyClosestPoint(GetFeetPosition());
|
||||
|
||||
// Update which point we are moving towards.
|
||||
// Note that we need to do this here because otherwise the remainingDistance field might be incorrect for 1 frame.
|
||||
// (due to interpolator.remainingDistance being incorrect).
|
||||
interpolator.MoveToCircleIntersection2D(position, pickNextWaypointDist, movementPlane);
|
||||
|
||||
var distanceToEnd = remainingDistance;
|
||||
if (distanceToEnd <= endReachedDistance) {
|
||||
reachedEndOfPath = true;
|
||||
OnTargetReached();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void ClearPath () {
|
||||
CancelCurrentPathRequest();
|
||||
if (path != null) path.Release(this);
|
||||
path = null;
|
||||
interpolator.SetPath(null);
|
||||
reachedEndOfPath = false;
|
||||
}
|
||||
|
||||
/// <summary>Called during either Update or FixedUpdate depending on if rigidbodies are used for movement or not</summary>
|
||||
protected override void MovementUpdateInternal (float deltaTime, out Vector3 nextPosition, out Quaternion nextRotation) {
|
||||
float currentAcceleration = maxAcceleration;
|
||||
|
||||
// If negative, calculate the acceleration from the max speed
|
||||
if (currentAcceleration < 0) currentAcceleration *= -maxSpeed;
|
||||
|
||||
if (updatePosition) {
|
||||
// Get our current position. We read from transform.position as few times as possible as it is relatively slow
|
||||
// (at least compared to a local variable)
|
||||
simulatedPosition = tr.position;
|
||||
}
|
||||
if (updateRotation) simulatedRotation = tr.rotation;
|
||||
|
||||
var currentPosition = simulatedPosition;
|
||||
|
||||
// Update which point we are moving towards
|
||||
interpolator.MoveToCircleIntersection2D(currentPosition, pickNextWaypointDist, movementPlane);
|
||||
var dir = movementPlane.ToPlane(steeringTarget - currentPosition);
|
||||
|
||||
// Calculate the distance to the end of the path
|
||||
float distanceToEnd = dir.magnitude + Mathf.Max(0, interpolator.remainingDistance);
|
||||
|
||||
// Check if we have reached the target
|
||||
var prevTargetReached = reachedEndOfPath;
|
||||
reachedEndOfPath = distanceToEnd <= endReachedDistance && interpolator.valid;
|
||||
if (!prevTargetReached && reachedEndOfPath) OnTargetReached();
|
||||
float slowdown;
|
||||
|
||||
// Normalized direction of where the agent is looking
|
||||
var forwards = movementPlane.ToPlane(simulatedRotation * (orientation == OrientationMode.YAxisForward ? Vector3.up : Vector3.forward));
|
||||
|
||||
// Check if we have a valid path to follow and some other script has not stopped the character
|
||||
bool stopped = isStopped || (reachedDestination && whenCloseToDestination == CloseToDestinationMode.Stop);
|
||||
if (interpolator.valid && !stopped) {
|
||||
// How fast to move depending on the distance to the destination.
|
||||
// Move slower as the character gets closer to the destination.
|
||||
// This is always a value between 0 and 1.
|
||||
slowdown = distanceToEnd < slowdownDistance? Mathf.Sqrt(distanceToEnd / slowdownDistance) : 1;
|
||||
|
||||
if (reachedEndOfPath && whenCloseToDestination == CloseToDestinationMode.Stop) {
|
||||
// Slow down as quickly as possible
|
||||
velocity2D -= Vector2.ClampMagnitude(velocity2D, currentAcceleration * deltaTime);
|
||||
} else {
|
||||
velocity2D += MovementUtilities.CalculateAccelerationToReachPoint(dir, dir.normalized*maxSpeed, velocity2D, currentAcceleration, rotationSpeed, maxSpeed, forwards) * deltaTime;
|
||||
}
|
||||
} else {
|
||||
slowdown = 1;
|
||||
// Slow down as quickly as possible
|
||||
velocity2D -= Vector2.ClampMagnitude(velocity2D, currentAcceleration * deltaTime);
|
||||
}
|
||||
|
||||
velocity2D = MovementUtilities.ClampVelocity(velocity2D, maxSpeed, slowdown, slowWhenNotFacingTarget && enableRotation, forwards);
|
||||
|
||||
ApplyGravity(deltaTime);
|
||||
|
||||
if (rvoController != null && rvoController.enabled) {
|
||||
// Send a message to the RVOController that we want to move
|
||||
// with this velocity. In the next simulation step, this
|
||||
// velocity will be processed and it will be fed back to the
|
||||
// rvo controller and finally it will be used by this script
|
||||
// when calling the CalculateMovementDelta method below
|
||||
|
||||
// Make sure that we don't move further than to the end point
|
||||
// of the path. If the RVO simulation FPS is low and we did
|
||||
// not do this, the agent might overshoot the target a lot.
|
||||
var rvoTarget = currentPosition + movementPlane.ToWorld(Vector2.ClampMagnitude(velocity2D, distanceToEnd), 0f);
|
||||
rvoController.SetTarget(rvoTarget, velocity2D.magnitude, maxSpeed);
|
||||
}
|
||||
|
||||
// Set how much the agent wants to move during this frame
|
||||
var delta2D = lastDeltaPosition = CalculateDeltaToMoveThisFrame(movementPlane.ToPlane(currentPosition), distanceToEnd, deltaTime);
|
||||
nextPosition = currentPosition + movementPlane.ToWorld(delta2D, verticalVelocity * lastDeltaTime);
|
||||
CalculateNextRotation(slowdown, out nextRotation);
|
||||
}
|
||||
|
||||
protected virtual void CalculateNextRotation (float slowdown, out Quaternion nextRotation) {
|
||||
if (lastDeltaTime > 0.00001f && enableRotation) {
|
||||
Vector2 desiredRotationDirection;
|
||||
if (rvoController != null && rvoController.enabled) {
|
||||
// When using local avoidance, use the actual velocity we are moving with if that velocity
|
||||
// is high enough, otherwise fall back to the velocity that we want to move with (velocity2D).
|
||||
// The local avoidance velocity can be very jittery when the character is close to standing still
|
||||
// as it constantly makes small corrections. We do not want the rotation of the character to be jittery.
|
||||
var actualVelocity = lastDeltaPosition/lastDeltaTime;
|
||||
desiredRotationDirection = Vector2.Lerp(velocity2D, actualVelocity, 4 * actualVelocity.magnitude / (maxSpeed + 0.0001f));
|
||||
} else {
|
||||
desiredRotationDirection = velocity2D;
|
||||
}
|
||||
|
||||
// Rotate towards the direction we are moving in.
|
||||
// Don't rotate when we are very close to the target.
|
||||
var currentRotationSpeed = rotationSpeed * Mathf.Max(0, (slowdown - 0.3f) / 0.7f);
|
||||
nextRotation = SimulateRotationTowards(desiredRotationDirection, currentRotationSpeed * lastDeltaTime);
|
||||
} else {
|
||||
// TODO: simulatedRotation
|
||||
nextRotation = rotation;
|
||||
}
|
||||
}
|
||||
|
||||
static NNConstraint cachedNNConstraint = NNConstraint.Default;
|
||||
protected override Vector3 ClampToNavmesh (Vector3 position, out bool positionChanged) {
|
||||
if (constrainInsideGraph) {
|
||||
cachedNNConstraint.tags = seeker.traversableTags;
|
||||
cachedNNConstraint.graphMask = seeker.graphMask;
|
||||
cachedNNConstraint.distanceXZ = true;
|
||||
var clampedPosition = AstarPath.active.GetNearest(position, cachedNNConstraint).position;
|
||||
|
||||
// We cannot simply check for equality because some precision may be lost
|
||||
// if any coordinate transformations are used.
|
||||
var difference = movementPlane.ToPlane(clampedPosition - position);
|
||||
float sqrDifference = difference.sqrMagnitude;
|
||||
if (sqrDifference > 0.001f*0.001f) {
|
||||
// The agent was outside the navmesh. Remove that component of the velocity
|
||||
// so that the velocity only goes along the direction of the wall, not into it
|
||||
velocity2D -= difference * Vector2.Dot(difference, velocity2D) / sqrDifference;
|
||||
|
||||
// Make sure the RVO system knows that there was a collision here
|
||||
// Otherwise other agents may think this agent continued
|
||||
// to move forwards and avoidance quality may suffer
|
||||
if (rvoController != null && rvoController.enabled) {
|
||||
rvoController.SetCollisionNormal(difference);
|
||||
}
|
||||
positionChanged = true;
|
||||
// Return the new position, but ignore any changes in the y coordinate from the ClampToNavmesh method as the y coordinates in the navmesh are rarely very accurate
|
||||
return position + movementPlane.ToWorld(difference);
|
||||
}
|
||||
}
|
||||
|
||||
positionChanged = false;
|
||||
return position;
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
[System.NonSerialized]
|
||||
int gizmoHash = 0;
|
||||
|
||||
[System.NonSerialized]
|
||||
float lastChangedTime = float.NegativeInfinity;
|
||||
|
||||
protected static readonly Color GizmoColor = new Color(46.0f/255, 104.0f/255, 201.0f/255);
|
||||
|
||||
protected override void OnDrawGizmos () {
|
||||
base.OnDrawGizmos();
|
||||
if (alwaysDrawGizmos) OnDrawGizmosInternal();
|
||||
}
|
||||
|
||||
protected override void OnDrawGizmosSelected () {
|
||||
base.OnDrawGizmosSelected();
|
||||
if (!alwaysDrawGizmos) OnDrawGizmosInternal();
|
||||
}
|
||||
|
||||
void OnDrawGizmosInternal () {
|
||||
var newGizmoHash = pickNextWaypointDist.GetHashCode() ^ slowdownDistance.GetHashCode() ^ endReachedDistance.GetHashCode();
|
||||
|
||||
if (newGizmoHash != gizmoHash && gizmoHash != 0) lastChangedTime = Time.realtimeSinceStartup;
|
||||
gizmoHash = newGizmoHash;
|
||||
float alpha = alwaysDrawGizmos ? 1 : Mathf.SmoothStep(1, 0, (Time.realtimeSinceStartup - lastChangedTime - 5f)/0.5f) * (UnityEditor.Selection.gameObjects.Length == 1 ? 1 : 0);
|
||||
|
||||
if (alpha > 0) {
|
||||
// Make sure the scene view is repainted while the gizmos are visible
|
||||
if (!alwaysDrawGizmos) UnityEditor.SceneView.RepaintAll();
|
||||
Draw.Gizmos.Line(position, steeringTarget, GizmoColor * new Color(1, 1, 1, alpha));
|
||||
Gizmos.matrix = Matrix4x4.TRS(position, transform.rotation * (orientation == OrientationMode.YAxisForward ? Quaternion.Euler(-90, 0, 0) : Quaternion.identity), Vector3.one);
|
||||
Draw.Gizmos.CircleXZ(Vector3.zero, pickNextWaypointDist, GizmoColor * new Color(1, 1, 1, alpha));
|
||||
Draw.Gizmos.CircleXZ(Vector3.zero, slowdownDistance, Color.Lerp(GizmoColor, Color.red, 0.5f) * new Color(1, 1, 1, alpha));
|
||||
Draw.Gizmos.CircleXZ(Vector3.zero, endReachedDistance, Color.Lerp(GizmoColor, Color.red, 0.8f) * new Color(1, 1, 1, alpha));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
protected override int OnUpgradeSerializedData (int version, bool unityThread) {
|
||||
// Approximately convert from a damping value to a degrees per second value.
|
||||
if (version < 1) rotationSpeed *= 90;
|
||||
return base.OnUpgradeSerializedData(version, unityThread);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f6eb1402c17e84a9282a7f0f62eb584f
|
||||
timeCreated: 1491225739
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
395
BlueWater/Assets/AstarPathfindingProject/Core/AI/IAstarAI.cs
Normal file
395
BlueWater/Assets/AstarPathfindingProject/Core/AI/IAstarAI.cs
Normal file
@ -0,0 +1,395 @@
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Pathfinding {
|
||||
/// <summary>
|
||||
/// Common interface for all movement scripts in the A* Pathfinding Project.
|
||||
/// See: <see cref="Pathfinding.AIPath"/>
|
||||
/// See: <see cref="Pathfinding.RichAI"/>
|
||||
/// See: <see cref="Pathfinding.AILerp"/>
|
||||
/// </summary>
|
||||
public interface IAstarAI {
|
||||
/// <summary>
|
||||
/// Radius of the agent in world units.
|
||||
/// This is visualized in the scene view as a yellow cylinder around the character.
|
||||
///
|
||||
/// Note: The <see cref="Pathfinding.AILerp"/> script doesn't really have any use of knowing the radius or the height of the character, so this property will always return 0 in that script.
|
||||
/// </summary>
|
||||
float radius { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Height of the agent in world units.
|
||||
/// This is visualized in the scene view as a yellow cylinder around the character.
|
||||
///
|
||||
/// This value is currently only used if an RVOController is attached to the same GameObject, otherwise it is only used for drawing nice gizmos in the scene view.
|
||||
/// However since the height value is used for some things, the radius field is always visible for consistency and easier visualization of the character.
|
||||
/// That said, it may be used for something in a future release.
|
||||
///
|
||||
/// Note: The <see cref="Pathfinding.AILerp"/> script doesn't really have any use of knowing the radius or the height of the character, so this property will always return 0 in that script.
|
||||
/// </summary>
|
||||
float height { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Position of the agent.
|
||||
/// In world space.
|
||||
/// See: <see cref="rotation"/>
|
||||
///
|
||||
/// If you want to move the agent you may use <see cref="Teleport"/> or <see cref="Move"/>.
|
||||
/// </summary>
|
||||
Vector3 position { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Rotation of the agent.
|
||||
/// In world space.
|
||||
/// See: <see cref="position"/>
|
||||
/// </summary>
|
||||
Quaternion rotation { get; set; }
|
||||
|
||||
/// <summary>Max speed in world units per second</summary>
|
||||
float maxSpeed { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Actual velocity that the agent is moving with.
|
||||
/// In world units per second.
|
||||
///
|
||||
/// See: <see cref="desiredVelocity"/>
|
||||
/// </summary>
|
||||
Vector3 velocity { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Velocity that this agent wants to move with.
|
||||
/// Includes gravity and local avoidance if applicable.
|
||||
/// In world units per second.
|
||||
///
|
||||
/// See: <see cref="velocity"/>
|
||||
/// </summary>
|
||||
Vector3 desiredVelocity { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Approximate remaining distance along the current path to the end of the path.
|
||||
/// The RichAI movement script approximates this distance since it is quite expensive to calculate the real distance.
|
||||
/// However it will be accurate when the agent is within 1 corner of the destination.
|
||||
/// You can use <see cref="GetRemainingPath"/> to calculate the actual remaining path more precisely.
|
||||
///
|
||||
/// The AIPath and AILerp scripts use a more accurate distance calculation at all times.
|
||||
///
|
||||
/// If the agent does not currently have a path, then positive infinity will be returned.
|
||||
///
|
||||
/// Note: This is the distance to the end of the path, which may or may not be at the <see cref="destination"/>. If the character cannot reach the destination it will try to move as close as possible to it.
|
||||
///
|
||||
/// Warning: Since path requests are asynchronous, there is a small delay between a path request being sent and this value being updated with the new calculated path.
|
||||
///
|
||||
/// See: <see cref="reachedDestination"/>
|
||||
/// See: <see cref="reachedEndOfPath"/>
|
||||
/// See: <see cref="pathPending"/>
|
||||
/// </summary>
|
||||
float remainingDistance { get; }
|
||||
|
||||
/// <summary>
|
||||
/// True if the ai has reached the <see cref="destination"/>.
|
||||
/// This is a best effort calculation to see if the <see cref="destination"/> has been reached.
|
||||
/// For the AIPath/RichAI scripts, this is when the character is within <see cref="AIPath.endReachedDistance"/> world units from the <see cref="destination"/>.
|
||||
/// For the AILerp script it is when the character is at the destination (±a very small margin).
|
||||
///
|
||||
/// This value will be updated immediately when the <see cref="destination"/> is changed (in contrast to <see cref="reachedEndOfPath)"/>, however since path requests are asynchronous
|
||||
/// it will use an approximation until it sees the real path result. What this property does is to check the distance to the end of the current path, and add to that the distance
|
||||
/// from the end of the path to the <see cref="destination"/> (i.e. is assumes it is possible to move in a straight line between the end of the current path to the destination) and then checks if that total
|
||||
/// distance is less than <see cref="endReachedDistance"/>. This property is therefore only a best effort, but it will work well for almost all use cases.
|
||||
///
|
||||
/// Furthermore it will not report that the destination is reached if the destination is above the head of the character or more than half the <see cref="height"/> of the character below its feet
|
||||
/// (so if you have a multilevel building, it is important that you configure the <see cref="height"/> of the character correctly).
|
||||
///
|
||||
/// The cases which could be problematic are if an agent is standing next to a very thin wall and the destination suddenly changes to the other side of that thin wall.
|
||||
/// During the time that it takes for the path to be calculated the agent may see itself as alredy having reached the destination because the destination only moved a very small distance (the wall was thin),
|
||||
/// even though it may actually be quite a long way around the wall to the other side.
|
||||
///
|
||||
/// In contrast to <see cref="reachedEndOfPath"/>, this property is immediately updated when the <see cref="destination"/> is changed.
|
||||
///
|
||||
/// <code>
|
||||
/// IEnumerator Start () {
|
||||
/// ai.destination = somePoint;
|
||||
/// // Start to search for a path to the destination immediately
|
||||
/// ai.SearchPath();
|
||||
/// // Wait until the agent has reached the destination
|
||||
/// while (!ai.reachedDestination) {
|
||||
/// yield return null;
|
||||
/// }
|
||||
/// // The agent has reached the destination now
|
||||
/// }
|
||||
/// </code>
|
||||
///
|
||||
/// See: <see cref="AIPath.endReachedDistance"/>
|
||||
/// See: <see cref="remainingDistance"/>
|
||||
/// See: <see cref="reachedEndOfPath"/>
|
||||
/// </summary>
|
||||
bool reachedDestination { get; }
|
||||
|
||||
/// <summary>
|
||||
/// True if the agent has reached the end of the current path.
|
||||
///
|
||||
/// Note that setting the <see cref="destination"/> does not immediately update the path, nor is there any guarantee that the
|
||||
/// AI will actually be able to reach the destination that you set. The AI will try to get as close as possible.
|
||||
/// Often you want to use <see cref="reachedDestination"/> instead which is easier to work with.
|
||||
///
|
||||
/// It is very hard to provide a method for detecting if the AI has reached the <see cref="destination"/> that works across all different games
|
||||
/// because the destination may not even lie on the navmesh and how that is handled differs from game to game (see also the code snippet in the docs for <see cref="destination)"/>.
|
||||
///
|
||||
/// See: <see cref="remainingDistance"/>
|
||||
/// See: <see cref="reachedDestination"/>
|
||||
/// </summary>
|
||||
bool reachedEndOfPath { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Position in the world that this agent should move to.
|
||||
///
|
||||
/// If no destination has been set yet, then (+infinity, +infinity, +infinity) will be returned.
|
||||
///
|
||||
/// Note that setting this property does not immediately cause the agent to recalculate its path.
|
||||
/// So it may take some time before the agent starts to move towards this point.
|
||||
/// Most movement scripts have a repathRate field which indicates how often the agent looks
|
||||
/// for a new path. You can also call the <see cref="SearchPath"/> method to immediately
|
||||
/// start to search for a new path. Paths are calculated asynchronously so when an agent starts to
|
||||
/// search for path it may take a few frames (usually 1 or 2) until the result is available.
|
||||
/// During this time the <see cref="pathPending"/> property will return true.
|
||||
///
|
||||
/// If you are setting a destination and then want to know when the agent has reached that destination
|
||||
/// then you could either use <see cref="reachedDestination"/> (recommended) or check both <see cref="pathPending"/> and <see cref="reachedEndOfPath"/>.
|
||||
/// Check the documentation for the respective fields to learn about their differences.
|
||||
///
|
||||
/// <code>
|
||||
/// IEnumerator Start () {
|
||||
/// ai.destination = somePoint;
|
||||
/// // Start to search for a path to the destination immediately
|
||||
/// ai.SearchPath();
|
||||
/// // Wait until the agent has reached the destination
|
||||
/// while (!ai.reachedDestination) {
|
||||
/// yield return null;
|
||||
/// }
|
||||
/// // The agent has reached the destination now
|
||||
/// }
|
||||
/// </code>
|
||||
/// <code>
|
||||
/// IEnumerator Start () {
|
||||
/// ai.destination = somePoint;
|
||||
/// // Start to search for a path to the destination immediately
|
||||
/// // Note that the result may not become available until after a few frames
|
||||
/// // ai.pathPending will be true while the path is being calculated
|
||||
/// ai.SearchPath();
|
||||
/// // Wait until we know for sure that the agent has calculated a path to the destination we set above
|
||||
/// while (ai.pathPending || !ai.reachedEndOfPath) {
|
||||
/// yield return null;
|
||||
/// }
|
||||
/// // The agent has reached the destination now
|
||||
/// }
|
||||
/// </code>
|
||||
/// </summary>
|
||||
Vector3 destination { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Enables or disables recalculating the path at regular intervals.
|
||||
/// Setting this to false does not stop any active path requests from being calculated or stop it from continuing to follow the current path.
|
||||
///
|
||||
/// Note that this only disables automatic path recalculations. If you call the <see cref="SearchPath()"/> method a path will still be calculated.
|
||||
///
|
||||
/// See: <see cref="canMove"/>
|
||||
/// See: <see cref="isStopped"/>
|
||||
/// </summary>
|
||||
bool canSearch { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Enables or disables movement completely.
|
||||
/// If you want the agent to stand still, but still react to local avoidance and use gravity: use <see cref="isStopped"/> instead.
|
||||
///
|
||||
/// This is also useful if you want to have full control over when the movement calculations run.
|
||||
/// Take a look at <see cref="MovementUpdate"/>
|
||||
///
|
||||
/// See: <see cref="canSearch"/>
|
||||
/// See: <see cref="isStopped"/>
|
||||
/// </summary>
|
||||
bool canMove { get; set; }
|
||||
|
||||
/// <summary>True if this agent currently has a path that it follows</summary>
|
||||
bool hasPath { get; }
|
||||
|
||||
/// <summary>True if a path is currently being calculated</summary>
|
||||
bool pathPending { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets if the agent should stop moving.
|
||||
/// If this is set to true the agent will immediately start to slow down as quickly as it can to come to a full stop.
|
||||
/// The agent will still react to local avoidance and gravity (if applicable), but it will not try to move in any particular direction.
|
||||
///
|
||||
/// The current path of the agent will not be cleared, so when this is set
|
||||
/// to false again the agent will continue moving along the previous path.
|
||||
///
|
||||
/// This is a purely user-controlled parameter, so for example it is not set automatically when the agent stops
|
||||
/// moving because it has reached the target. Use <see cref="reachedEndOfPath"/> for that.
|
||||
///
|
||||
/// If this property is set to true while the agent is traversing an off-mesh link (RichAI script only), then the agent will
|
||||
/// continue traversing the link and stop once it has completed it.
|
||||
///
|
||||
/// Note: This is not the same as the <see cref="canMove"/> setting which some movement scripts have. The <see cref="canMove"/> setting
|
||||
/// disables movement calculations completely (which among other things makes it not be affected by local avoidance or gravity).
|
||||
/// For the AILerp movement script which doesn't use gravity or local avoidance anyway changing this property is very similar to
|
||||
/// changing <see cref="canMove"/>.
|
||||
///
|
||||
/// The <see cref="steeringTarget"/> property will continue to indicate the point which the agent would move towards if it would not be stopped.
|
||||
/// </summary>
|
||||
bool isStopped { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Point on the path which the agent is currently moving towards.
|
||||
/// This is usually a point a small distance ahead of the agent
|
||||
/// or the end of the path.
|
||||
///
|
||||
/// If the agent does not have a path at the moment, then the agent's current position will be returned.
|
||||
/// </summary>
|
||||
Vector3 steeringTarget { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Called when the agent recalculates its path.
|
||||
/// This is called both for automatic path recalculations (see <see cref="canSearch)"/> and manual ones (see <see cref="SearchPath)"/>.
|
||||
///
|
||||
/// See: Take a look at the <see cref="Pathfinding.AIDestinationSetter"/> source code for an example of how it can be used.
|
||||
/// </summary>
|
||||
System.Action onSearchPath { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Fills buffer with the remaining path.
|
||||
///
|
||||
/// <code>
|
||||
/// var buffer = new List<Vector3>();
|
||||
///
|
||||
/// ai.GetRemainingPath(buffer, out bool stale);
|
||||
/// for (int i = 0; i < buffer.Count - 1; i++) {
|
||||
/// Debug.DrawLine(buffer[i], buffer[i+1], Color.red);
|
||||
/// }
|
||||
/// </code>
|
||||
/// [Open online documentation to see images]
|
||||
/// </summary>
|
||||
/// <param name="buffer">The buffer will be cleared and replaced with the path. The first point is the current position of the agent.</param>
|
||||
/// <param name="stale">May be true if the path is invalid in some way. For example if the agent has no path or (for the RichAI script only) if the agent has detected that some nodes in the path have been destroyed.</param>
|
||||
void GetRemainingPath(List<Vector3> buffer, out bool stale);
|
||||
|
||||
/// <summary>
|
||||
/// Recalculate the current path.
|
||||
/// You can for example use this if you want very quick reaction times when you have changed the <see cref="destination"/>
|
||||
/// so that the agent does not have to wait until the next automatic path recalculation (see <see cref="canSearch)"/>.
|
||||
///
|
||||
/// If there is an ongoing path calculation, it will be canceled, so make sure you leave time for the paths to get calculated before calling this function again.
|
||||
/// A canceled path will show up in the log with the message "Canceled by script" (see <see cref="Seeker.CancelCurrentPathRequest())"/>.
|
||||
///
|
||||
/// If no <see cref="destination"/> has been set yet then nothing will be done.
|
||||
///
|
||||
/// Note: The path result may not become available until after a few frames.
|
||||
/// During the calculation time the <see cref="pathPending"/> property will return true.
|
||||
///
|
||||
/// See: <see cref="pathPending"/>
|
||||
/// </summary>
|
||||
void SearchPath();
|
||||
|
||||
/// <summary>
|
||||
/// Make the AI follow the specified path.
|
||||
///
|
||||
/// In case the path has not been calculated, the script will call seeker.StartPath to calculate it.
|
||||
/// This means the AI may not actually start to follow the path until in a few frames when the path has been calculated.
|
||||
/// The <see cref="pathPending"/> field will as usual return true while the path is being calculated.
|
||||
///
|
||||
/// In case the path has already been calculated it will immediately replace the current path the AI is following.
|
||||
/// This is useful if you want to replace how the AI calculates its paths.
|
||||
/// Note that if you calculate the path using seeker.StartPath then this script will already pick it up because it is listening for
|
||||
/// all paths that the Seeker finishes calculating. In that case you do not need to call this function.
|
||||
///
|
||||
/// If you pass null as a parameter then the current path will be cleared and the agent will stop moving.
|
||||
/// Note than unless you have also disabled <see cref="canSearch"/> then the agent will soon recalculate its path and start moving again.
|
||||
///
|
||||
/// You can disable the automatic path recalculation by setting the <see cref="canSearch"/> field to false.
|
||||
///
|
||||
/// <code>
|
||||
/// // Disable the automatic path recalculation
|
||||
/// ai.canSearch = false;
|
||||
/// var pointToAvoid = enemy.position;
|
||||
/// // Make the AI flee from the enemy.
|
||||
/// // The path will be about 20 world units long (the default cost of moving 1 world unit is 1000).
|
||||
/// var path = FleePath.Construct(ai.position, pointToAvoid, 1000 * 20);
|
||||
/// ai.SetPath(path);
|
||||
///
|
||||
/// // If you want to make use of properties like ai.reachedDestination or ai.remainingDistance or similar
|
||||
/// // you should also set the destination property to something reasonable.
|
||||
/// // Since the agent's own path recalculation is disabled, setting this will not affect how the paths are calculated.
|
||||
/// // ai.destination = ...
|
||||
/// </code>
|
||||
/// </summary>
|
||||
/// <param name="path">The path to follow.</param>
|
||||
/// <param name="updateDestinationFromPath">If true, the #destination property will be set to the end point of the path. If false, the previous destination value will be kept.</param>
|
||||
void SetPath(Path path, bool updateDestinationFromPath = true);
|
||||
|
||||
/// <summary>
|
||||
/// Instantly move the agent to a new position.
|
||||
/// This will trigger a path recalculation (if clearPath is true, which is the default) so if you want to teleport the agent and change its <see cref="destination"/>
|
||||
/// it is recommended that you set the <see cref="destination"/> before calling this method.
|
||||
///
|
||||
/// The current path will be cleared by default.
|
||||
///
|
||||
/// See: Works similarly to Unity's NavmeshAgent.Warp.
|
||||
/// See: <see cref="SearchPath"/>
|
||||
/// </summary>
|
||||
void Teleport(Vector3 newPosition, bool clearPath = true);
|
||||
|
||||
/// <summary>
|
||||
/// Move the agent.
|
||||
///
|
||||
/// This is intended for external movement forces such as those applied by wind, conveyor belts, knockbacks etc.
|
||||
///
|
||||
/// Some movement scripts may ignore this completely (notably the AILerp script) if it does not have
|
||||
/// any concept of being moved externally.
|
||||
///
|
||||
/// The agent will not be moved immediately when calling this method. Instead this offset will be stored and then
|
||||
/// applied the next time the agent runs its movement calculations (which is usually later this frame or the next frame).
|
||||
/// If you want to move the agent immediately then call:
|
||||
/// <code>
|
||||
/// ai.Move(someVector);
|
||||
/// ai.FinalizeMovement(ai.position, ai.rotation);
|
||||
/// </code>
|
||||
/// </summary>
|
||||
/// <param name="deltaPosition">Direction and distance to move the agent in world space.</param>
|
||||
void Move(Vector3 deltaPosition);
|
||||
|
||||
/// <summary>
|
||||
/// Calculate how the character wants to move during this frame.
|
||||
///
|
||||
/// Note that this does not actually move the character. You need to call <see cref="FinalizeMovement"/> for that.
|
||||
/// This is called automatically unless <see cref="canMove"/> is false.
|
||||
///
|
||||
/// To handle movement yourself you can disable <see cref="canMove"/> and call this method manually.
|
||||
/// This code will replicate the normal behavior of the component:
|
||||
/// <code>
|
||||
/// void Update () {
|
||||
/// // Disable the AIs own movement code
|
||||
/// ai.canMove = false;
|
||||
/// Vector3 nextPosition;
|
||||
/// Quaternion nextRotation;
|
||||
/// // Calculate how the AI wants to move
|
||||
/// ai.MovementUpdate(Time.deltaTime, out nextPosition, out nextRotation);
|
||||
/// // Modify nextPosition and nextRotation in any way you wish
|
||||
/// // Actually move the AI
|
||||
/// ai.FinalizeMovement(nextPosition, nextRotation);
|
||||
/// }
|
||||
/// </code>
|
||||
/// </summary>
|
||||
/// <param name="deltaTime">time to simulate movement for. Usually set to Time.deltaTime.</param>
|
||||
/// <param name="nextPosition">the position that the agent wants to move to during this frame.</param>
|
||||
/// <param name="nextRotation">the rotation that the agent wants to rotate to during this frame.</param>
|
||||
void MovementUpdate(float deltaTime, out Vector3 nextPosition, out Quaternion nextRotation);
|
||||
|
||||
/// <summary>
|
||||
/// Move the agent.
|
||||
/// To be called as the last step when you are handling movement manually.
|
||||
///
|
||||
/// The movement will be clamped to the navmesh if applicable (this is done for the RichAI movement script).
|
||||
///
|
||||
/// See: <see cref="MovementUpdate"/> for a code example.
|
||||
/// </summary>
|
||||
void FinalizeMovement(Vector3 nextPosition, Quaternion nextRotation);
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b7438f3f6b9404f05ab7f584f92aa7d5
|
||||
timeCreated: 1495013922
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,4 @@
|
||||
|
||||
// This file has been removed from the project. Since UnityPackages cannot
|
||||
// delete files, only replace them, this message is left here to prevent old
|
||||
// files from causing compiler errors
|
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 20549335d45df4a329ece093b865221b
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
591
BlueWater/Assets/AstarPathfindingProject/Core/AI/RichAI.cs
Normal file
591
BlueWater/Assets/AstarPathfindingProject/Core/AI/RichAI.cs
Normal file
@ -0,0 +1,591 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Pathfinding {
|
||||
using Pathfinding.RVO;
|
||||
using Pathfinding.Util;
|
||||
|
||||
[AddComponentMenu("Pathfinding/AI/RichAI (3D, for navmesh)")]
|
||||
/// <summary>
|
||||
/// Advanced AI for navmesh based graphs.
|
||||
///
|
||||
/// [Open online documentation to see images]
|
||||
///
|
||||
/// See: movementscripts (view in online documentation for working links)
|
||||
/// </summary>
|
||||
public partial class RichAI : AIBase, IAstarAI {
|
||||
/// <summary>
|
||||
/// Max acceleration of the agent.
|
||||
/// In world units per second per second.
|
||||
/// </summary>
|
||||
public float acceleration = 5;
|
||||
|
||||
/// <summary>
|
||||
/// Max rotation speed of the agent.
|
||||
/// In degrees per second.
|
||||
/// </summary>
|
||||
public float rotationSpeed = 360;
|
||||
|
||||
/// <summary>
|
||||
/// How long before reaching the end of the path to start to slow down.
|
||||
/// A lower value will make the agent stop more abruptly.
|
||||
///
|
||||
/// Note: The agent may require more time to slow down if
|
||||
/// its maximum <see cref="acceleration"/> is not high enough.
|
||||
///
|
||||
/// If set to zero the agent will not even attempt to slow down.
|
||||
/// This can be useful if the target point is not a point you want the agent to stop at
|
||||
/// but it might for example be the player and you want the AI to slam into the player.
|
||||
///
|
||||
/// Note: A value of zero will behave differently from a small but non-zero value (such as 0.0001).
|
||||
/// When it is non-zero the agent will still respect its <see cref="acceleration"/> when determining if it needs
|
||||
/// to slow down, but if it is zero it will disable that check.
|
||||
/// This is useful if the <see cref="destination"/> is not a point where you want the agent to stop.
|
||||
///
|
||||
/// \htmlonly <video class="tinyshadow" controls loop><source src="images/richai_slowdown_time.mp4" type="video/mp4"></video> \endhtmlonly
|
||||
/// </summary>
|
||||
public float slowdownTime = 0.5f;
|
||||
|
||||
/// <summary>
|
||||
/// Max distance to the endpoint to consider it reached.
|
||||
///
|
||||
/// See: <see cref="reachedEndOfPath"/>
|
||||
/// See: <see cref="OnTargetReached"/>
|
||||
/// </summary>
|
||||
public float endReachedDistance = 0.01f;
|
||||
|
||||
/// <summary>
|
||||
/// Force to avoid walls with.
|
||||
/// The agent will try to steer away from walls slightly.
|
||||
///
|
||||
/// See: <see cref="wallDist"/>
|
||||
/// </summary>
|
||||
public float wallForce = 3;
|
||||
|
||||
/// <summary>
|
||||
/// Walls within this range will be used for avoidance.
|
||||
/// Setting this to zero disables wall avoidance and may improve performance slightly
|
||||
///
|
||||
/// See: <see cref="wallForce"/>
|
||||
/// </summary>
|
||||
public float wallDist = 1;
|
||||
|
||||
/// <summary>
|
||||
/// Use funnel simplification.
|
||||
/// On tiled navmesh maps, but sometimes on normal ones as well, it can be good to simplify
|
||||
/// the funnel as a post-processing step to make the paths straighter.
|
||||
///
|
||||
/// This has a moderate performance impact during frames when a path calculation is completed.
|
||||
///
|
||||
/// The RichAI script uses its own internal funnel algorithm, so you never
|
||||
/// need to attach the FunnelModifier component.
|
||||
///
|
||||
/// [Open online documentation to see images]
|
||||
///
|
||||
/// See: <see cref="Pathfinding.FunnelModifier"/>
|
||||
/// </summary>
|
||||
public bool funnelSimplification = false;
|
||||
|
||||
/// <summary>
|
||||
/// Slow down when not facing the target direction.
|
||||
/// Incurs at a small performance overhead.
|
||||
/// </summary>
|
||||
public bool slowWhenNotFacingTarget = true;
|
||||
|
||||
/// <summary>
|
||||
/// Called when the agent starts to traverse an off-mesh link.
|
||||
/// Register to this callback to handle off-mesh links in a custom way.
|
||||
///
|
||||
/// If this event is set to null then the agent will fall back to traversing
|
||||
/// off-mesh links using a very simple linear interpolation.
|
||||
///
|
||||
/// <code>
|
||||
/// void OnEnable () {
|
||||
/// ai = GetComponent<RichAI>();
|
||||
/// if (ai != null) ai.onTraverseOffMeshLink += TraverseOffMeshLink;
|
||||
/// }
|
||||
///
|
||||
/// void OnDisable () {
|
||||
/// if (ai != null) ai.onTraverseOffMeshLink -= TraverseOffMeshLink;
|
||||
/// }
|
||||
///
|
||||
/// IEnumerator TraverseOffMeshLink (RichSpecial link) {
|
||||
/// // Traverse the link over 1 second
|
||||
/// float startTime = Time.time;
|
||||
///
|
||||
/// while (Time.time < startTime + 1) {
|
||||
/// transform.position = Vector3.Lerp(link.first.position, link.second.position, Time.time - startTime);
|
||||
/// yield return null;
|
||||
/// }
|
||||
/// transform.position = link.second.position;
|
||||
/// }
|
||||
/// </code>
|
||||
/// </summary>
|
||||
public System.Func<RichSpecial, IEnumerator> onTraverseOffMeshLink;
|
||||
|
||||
/// <summary>Holds the current path that this agent is following</summary>
|
||||
protected readonly RichPath richPath = new RichPath();
|
||||
|
||||
protected bool delayUpdatePath;
|
||||
protected bool lastCorner;
|
||||
|
||||
/// <summary>Distance to <see cref="steeringTarget"/> in the movement plane</summary>
|
||||
protected float distanceToSteeringTarget = float.PositiveInfinity;
|
||||
|
||||
protected readonly List<Vector3> nextCorners = new List<Vector3>();
|
||||
protected readonly List<Vector3> wallBuffer = new List<Vector3>();
|
||||
|
||||
public bool traversingOffMeshLink { get; protected set; }
|
||||
|
||||
/// <summary>\copydoc Pathfinding::IAstarAI::remainingDistance</summary>
|
||||
public float remainingDistance {
|
||||
get {
|
||||
return distanceToSteeringTarget + Vector3.Distance(steeringTarget, richPath.Endpoint);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>\copydoc Pathfinding::IAstarAI::reachedEndOfPath</summary>
|
||||
public bool reachedEndOfPath { get { return approachingPathEndpoint && distanceToSteeringTarget < endReachedDistance; } }
|
||||
|
||||
/// <summary>\copydoc Pathfinding::IAstarAI::reachedDestination</summary>
|
||||
public bool reachedDestination {
|
||||
get {
|
||||
if (!reachedEndOfPath) return false;
|
||||
// Note: distanceToSteeringTarget is the distance to the end of the path when approachingPathEndpoint is true
|
||||
if (approachingPathEndpoint && distanceToSteeringTarget + movementPlane.ToPlane(destination - richPath.Endpoint).magnitude > endReachedDistance) return false;
|
||||
|
||||
// Don't do height checks in 2D mode
|
||||
if (orientation != OrientationMode.YAxisForward) {
|
||||
// Check if the destination is above the head of the character or far below the feet of it
|
||||
float yDifference;
|
||||
movementPlane.ToPlane(destination - position, out yDifference);
|
||||
var h = tr.localScale.y * height;
|
||||
if (yDifference > h || yDifference < -h*0.5) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>\copydoc Pathfinding::IAstarAI::hasPath</summary>
|
||||
public bool hasPath { get { return richPath.GetCurrentPart() != null; } }
|
||||
|
||||
/// <summary>\copydoc Pathfinding::IAstarAI::pathPending</summary>
|
||||
public bool pathPending { get { return waitingForPathCalculation || delayUpdatePath; } }
|
||||
|
||||
/// <summary>\copydoc Pathfinding::IAstarAI::steeringTarget</summary>
|
||||
public Vector3 steeringTarget { get; protected set; }
|
||||
|
||||
/// <summary>\copydoc Pathfinding::IAstarAI::radius</summary>
|
||||
float IAstarAI.radius { get { return radius; } set { radius = value; } }
|
||||
|
||||
/// <summary>\copydoc Pathfinding::IAstarAI::height</summary>
|
||||
float IAstarAI.height { get { return height; } set { height = value; } }
|
||||
|
||||
/// <summary>\copydoc Pathfinding::IAstarAI::maxSpeed</summary>
|
||||
float IAstarAI.maxSpeed { get { return maxSpeed; } set { maxSpeed = value; } }
|
||||
|
||||
/// <summary>\copydoc Pathfinding::IAstarAI::canSearch</summary>
|
||||
bool IAstarAI.canSearch { get { return canSearch; } set { canSearch = value; } }
|
||||
|
||||
/// <summary>\copydoc Pathfinding::IAstarAI::canMove</summary>
|
||||
bool IAstarAI.canMove { get { return canMove; } set { canMove = value; } }
|
||||
|
||||
/// <summary>
|
||||
/// True if approaching the last waypoint in the current part of the path.
|
||||
/// Path parts are separated by off-mesh links.
|
||||
///
|
||||
/// See: <see cref="approachingPathEndpoint"/>
|
||||
/// </summary>
|
||||
public bool approachingPartEndpoint {
|
||||
get {
|
||||
return lastCorner && nextCorners.Count == 1;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// True if approaching the last waypoint of all parts in the current path.
|
||||
/// Path parts are separated by off-mesh links.
|
||||
///
|
||||
/// See: <see cref="approachingPartEndpoint"/>
|
||||
/// </summary>
|
||||
public bool approachingPathEndpoint {
|
||||
get {
|
||||
return approachingPartEndpoint && richPath.IsLastPart;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// \copydoc Pathfinding::IAstarAI::Teleport
|
||||
///
|
||||
/// When setting transform.position directly the agent
|
||||
/// will be clamped to the part of the navmesh it can
|
||||
/// reach, so it may not end up where you wanted it to.
|
||||
/// This ensures that the agent can move to any part of the navmesh.
|
||||
/// </summary>
|
||||
public override void Teleport (Vector3 newPosition, bool clearPath = true) {
|
||||
// Clamp the new position to the navmesh
|
||||
var nearest = AstarPath.active != null? AstarPath.active.GetNearest(newPosition) : new NNInfo();
|
||||
float elevation;
|
||||
|
||||
movementPlane.ToPlane(newPosition, out elevation);
|
||||
newPosition = movementPlane.ToWorld(movementPlane.ToPlane(nearest.node != null ? nearest.position : newPosition), elevation);
|
||||
base.Teleport(newPosition, clearPath);
|
||||
}
|
||||
|
||||
/// <summary>Called when the component is disabled</summary>
|
||||
protected override void OnDisable () {
|
||||
// Note that the AIBase.OnDisable call will also stop all coroutines
|
||||
base.OnDisable();
|
||||
traversingOffMeshLink = false;
|
||||
// Stop the off mesh link traversal coroutine
|
||||
StopAllCoroutines();
|
||||
}
|
||||
|
||||
protected override bool shouldRecalculatePath {
|
||||
get {
|
||||
// Don't automatically recalculate the path in the middle of an off-mesh link
|
||||
return base.shouldRecalculatePath && !traversingOffMeshLink;
|
||||
}
|
||||
}
|
||||
|
||||
public override void SearchPath () {
|
||||
// Calculate paths after the current off-mesh link has been completed
|
||||
if (traversingOffMeshLink) {
|
||||
delayUpdatePath = true;
|
||||
} else {
|
||||
base.SearchPath();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnPathComplete (Path p) {
|
||||
waitingForPathCalculation = false;
|
||||
p.Claim(this);
|
||||
|
||||
if (p.error) {
|
||||
p.Release(this);
|
||||
return;
|
||||
}
|
||||
|
||||
if (traversingOffMeshLink) {
|
||||
delayUpdatePath = true;
|
||||
} else {
|
||||
// The RandomPath and MultiTargetPath do not have a well defined destination that could have been
|
||||
// set before the paths were calculated. So we instead set the destination here so that some properties
|
||||
// like #reachedDestination and #remainingDistance work correctly.
|
||||
if (p is RandomPath rpath) {
|
||||
destination = rpath.originalEndPoint;
|
||||
} else if (p is MultiTargetPath mpath) {
|
||||
destination = mpath.originalEndPoint;
|
||||
}
|
||||
|
||||
richPath.Initialize(seeker, p, true, funnelSimplification);
|
||||
|
||||
// Check if we have already reached the end of the path
|
||||
// We need to do this here to make sure that the #reachedEndOfPath
|
||||
// property is up to date.
|
||||
var part = richPath.GetCurrentPart() as RichFunnel;
|
||||
if (part != null) {
|
||||
if (updatePosition) simulatedPosition = tr.position;
|
||||
|
||||
// Note: UpdateTarget has some side effects like setting the nextCorners list and the lastCorner field
|
||||
var localPosition = movementPlane.ToPlane(UpdateTarget(part));
|
||||
|
||||
// Target point
|
||||
steeringTarget = nextCorners[0];
|
||||
Vector2 targetPoint = movementPlane.ToPlane(steeringTarget);
|
||||
distanceToSteeringTarget = (targetPoint - localPosition).magnitude;
|
||||
|
||||
if (lastCorner && nextCorners.Count == 1 && distanceToSteeringTarget <= endReachedDistance) {
|
||||
NextPart();
|
||||
}
|
||||
}
|
||||
}
|
||||
p.Release(this);
|
||||
}
|
||||
|
||||
protected override void ClearPath () {
|
||||
CancelCurrentPathRequest();
|
||||
richPath.Clear();
|
||||
lastCorner = false;
|
||||
delayUpdatePath = false;
|
||||
distanceToSteeringTarget = float.PositiveInfinity;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Declare that the AI has completely traversed the current part.
|
||||
/// This will skip to the next part, or call OnTargetReached if this was the last part
|
||||
/// </summary>
|
||||
protected void NextPart () {
|
||||
if (!richPath.CompletedAllParts) {
|
||||
if (!richPath.IsLastPart) lastCorner = false;
|
||||
richPath.NextPart();
|
||||
if (richPath.CompletedAllParts) {
|
||||
OnTargetReached();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>\copydoc Pathfinding::IAstarAI::GetRemainingPath</summary>
|
||||
public void GetRemainingPath (List<Vector3> buffer, out bool stale) {
|
||||
richPath.GetRemainingPath(buffer, simulatedPosition, out stale);
|
||||
}
|
||||
|
||||
/// <summary>Called when the end of the path is reached</summary>
|
||||
protected virtual void OnTargetReached () {
|
||||
}
|
||||
|
||||
protected virtual Vector3 UpdateTarget (RichFunnel fn) {
|
||||
nextCorners.Clear();
|
||||
|
||||
// This method assumes simulatedPosition is up to date as our current position.
|
||||
// We read and write to tr.position as few times as possible since doing so
|
||||
// is much slower than to read and write from/to a local/member variable.
|
||||
bool requiresRepath;
|
||||
Vector3 position = fn.Update(simulatedPosition, nextCorners, 2, out lastCorner, out requiresRepath);
|
||||
|
||||
if (requiresRepath && !waitingForPathCalculation && canSearch) {
|
||||
// TODO: What if canSearch is false? How do we notify other scripts that might be handling the path calculation that a new path needs to be calculated?
|
||||
SearchPath();
|
||||
}
|
||||
|
||||
return position;
|
||||
}
|
||||
|
||||
/// <summary>Called during either Update or FixedUpdate depending on if rigidbodies are used for movement or not</summary>
|
||||
protected override void MovementUpdateInternal (float deltaTime, out Vector3 nextPosition, out Quaternion nextRotation) {
|
||||
if (updatePosition) simulatedPosition = tr.position;
|
||||
if (updateRotation) simulatedRotation = tr.rotation;
|
||||
|
||||
RichPathPart currentPart = richPath.GetCurrentPart();
|
||||
|
||||
if (currentPart is RichSpecial) {
|
||||
// Start traversing the off mesh link if we haven't done it yet
|
||||
if (!traversingOffMeshLink && !richPath.CompletedAllParts) {
|
||||
StartCoroutine(TraverseSpecial(currentPart as RichSpecial));
|
||||
}
|
||||
|
||||
nextPosition = steeringTarget = simulatedPosition;
|
||||
nextRotation = rotation;
|
||||
} else {
|
||||
var funnel = currentPart as RichFunnel;
|
||||
|
||||
// Check if we have a valid path to follow and some other script has not stopped the character
|
||||
if (funnel != null && !isStopped) {
|
||||
TraverseFunnel(funnel, deltaTime, out nextPosition, out nextRotation);
|
||||
} else {
|
||||
// Unknown, null path part, or the character is stopped
|
||||
// Slow down as quickly as possible
|
||||
velocity2D -= Vector2.ClampMagnitude(velocity2D, acceleration * deltaTime);
|
||||
FinalMovement(simulatedPosition, deltaTime, float.PositiveInfinity, 1f, out nextPosition, out nextRotation);
|
||||
steeringTarget = simulatedPosition;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TraverseFunnel (RichFunnel fn, float deltaTime, out Vector3 nextPosition, out Quaternion nextRotation) {
|
||||
// Clamp the current position to the navmesh
|
||||
// and update the list of upcoming corners in the path
|
||||
// and store that in the 'nextCorners' field
|
||||
var position3D = UpdateTarget(fn);
|
||||
float elevation;
|
||||
Vector2 position = movementPlane.ToPlane(position3D, out elevation);
|
||||
|
||||
// Only find nearby walls every 5th frame to improve performance
|
||||
if (Time.frameCount % 5 == 0 && wallForce > 0 && wallDist > 0) {
|
||||
wallBuffer.Clear();
|
||||
fn.FindWalls(wallBuffer, wallDist);
|
||||
}
|
||||
|
||||
// Target point
|
||||
steeringTarget = nextCorners[0];
|
||||
Vector2 targetPoint = movementPlane.ToPlane(steeringTarget);
|
||||
// Direction to target
|
||||
Vector2 dir = targetPoint - position;
|
||||
|
||||
// Normalized direction to the target
|
||||
Vector2 normdir = VectorMath.Normalize(dir, out distanceToSteeringTarget);
|
||||
// Calculate force from walls
|
||||
Vector2 wallForceVector = CalculateWallForce(position, elevation, normdir);
|
||||
Vector2 targetVelocity;
|
||||
|
||||
if (approachingPartEndpoint) {
|
||||
targetVelocity = slowdownTime > 0 ? Vector2.zero : normdir * maxSpeed;
|
||||
|
||||
// Reduce the wall avoidance force as we get closer to our target
|
||||
wallForceVector *= System.Math.Min(distanceToSteeringTarget/0.5f, 1);
|
||||
|
||||
if (distanceToSteeringTarget <= endReachedDistance) {
|
||||
// Reached the end of the path or an off mesh link
|
||||
NextPart();
|
||||
}
|
||||
} else {
|
||||
var nextNextCorner = nextCorners.Count > 1 ? movementPlane.ToPlane(nextCorners[1]) : position + 2*dir;
|
||||
targetVelocity = (nextNextCorner - targetPoint).normalized * maxSpeed;
|
||||
}
|
||||
|
||||
var forwards = movementPlane.ToPlane(simulatedRotation * (orientation == OrientationMode.YAxisForward ? Vector3.up : Vector3.forward));
|
||||
Vector2 accel = MovementUtilities.CalculateAccelerationToReachPoint(targetPoint - position, targetVelocity, velocity2D, acceleration, rotationSpeed, maxSpeed, forwards);
|
||||
|
||||
// Update the velocity using the acceleration
|
||||
velocity2D += (accel + wallForceVector*wallForce)*deltaTime;
|
||||
|
||||
// Distance to the end of the path (almost as the crow flies)
|
||||
var distanceToEndOfPath = distanceToSteeringTarget + Vector3.Distance(steeringTarget, fn.exactEnd);
|
||||
var slowdownFactor = distanceToEndOfPath < maxSpeed * slowdownTime? Mathf.Sqrt(distanceToEndOfPath / (maxSpeed * slowdownTime)) : 1;
|
||||
FinalMovement(position3D, deltaTime, distanceToEndOfPath, slowdownFactor, out nextPosition, out nextRotation);
|
||||
}
|
||||
|
||||
void FinalMovement (Vector3 position3D, float deltaTime, float distanceToEndOfPath, float slowdownFactor, out Vector3 nextPosition, out Quaternion nextRotation) {
|
||||
var forwards = movementPlane.ToPlane(simulatedRotation * (orientation == OrientationMode.YAxisForward ? Vector3.up : Vector3.forward));
|
||||
|
||||
velocity2D = MovementUtilities.ClampVelocity(velocity2D, maxSpeed, slowdownFactor, slowWhenNotFacingTarget && enableRotation, forwards);
|
||||
|
||||
ApplyGravity(deltaTime);
|
||||
|
||||
if (rvoController != null && rvoController.enabled) {
|
||||
// Send a message to the RVOController that we want to move
|
||||
// with this velocity. In the next simulation step, this
|
||||
// velocity will be processed and it will be fed back to the
|
||||
// rvo controller and finally it will be used by this script
|
||||
// when calling the CalculateMovementDelta method below
|
||||
|
||||
// Make sure that we don't move further than to the end point
|
||||
// of the path. If the RVO simulation FPS is low and we did
|
||||
// not do this, the agent might overshoot the target a lot.
|
||||
var rvoTarget = position3D + movementPlane.ToWorld(Vector2.ClampMagnitude(velocity2D, distanceToEndOfPath));
|
||||
rvoController.SetTarget(rvoTarget, velocity2D.magnitude, maxSpeed);
|
||||
}
|
||||
|
||||
// Direction and distance to move during this frame
|
||||
var deltaPosition = lastDeltaPosition = CalculateDeltaToMoveThisFrame(movementPlane.ToPlane(position3D), distanceToEndOfPath, deltaTime);
|
||||
|
||||
// Rotate towards the direction we are moving in
|
||||
// Slow down the rotation of the character very close to the endpoint of the path to prevent oscillations
|
||||
var rotationSpeedFactor = approachingPartEndpoint ? Mathf.Clamp01(1.1f * slowdownFactor - 0.1f) : 1f;
|
||||
nextRotation = enableRotation ? SimulateRotationTowards(deltaPosition, rotationSpeed * rotationSpeedFactor * deltaTime) : simulatedRotation;
|
||||
|
||||
nextPosition = position3D + movementPlane.ToWorld(deltaPosition, verticalVelocity * deltaTime);
|
||||
}
|
||||
|
||||
protected override Vector3 ClampToNavmesh (Vector3 position, out bool positionChanged) {
|
||||
if (richPath != null) {
|
||||
var funnel = richPath.GetCurrentPart() as RichFunnel;
|
||||
if (funnel != null) {
|
||||
var clampedPosition = funnel.ClampToNavmesh(position);
|
||||
|
||||
// We cannot simply check for equality because some precision may be lost
|
||||
// if any coordinate transformations are used.
|
||||
var difference = movementPlane.ToPlane(clampedPosition - position);
|
||||
float sqrDifference = difference.sqrMagnitude;
|
||||
if (sqrDifference > 0.001f*0.001f) {
|
||||
// The agent was outside the navmesh. Remove that component of the velocity
|
||||
// so that the velocity only goes along the direction of the wall, not into it
|
||||
velocity2D -= difference * Vector2.Dot(difference, velocity2D) / sqrDifference;
|
||||
|
||||
// Make sure the RVO system knows that there was a collision here
|
||||
// Otherwise other agents may think this agent continued
|
||||
// to move forwards and avoidance quality may suffer
|
||||
if (rvoController != null && rvoController.enabled) {
|
||||
rvoController.SetCollisionNormal(difference);
|
||||
}
|
||||
positionChanged = true;
|
||||
// Return the new position, but ignore any changes in the y coordinate from the ClampToNavmesh method as the y coordinates in the navmesh are rarely very accurate
|
||||
return position + movementPlane.ToWorld(difference);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
positionChanged = false;
|
||||
return position;
|
||||
}
|
||||
|
||||
Vector2 CalculateWallForce (Vector2 position, float elevation, Vector2 directionToTarget) {
|
||||
if (wallForce <= 0 || wallDist <= 0) return Vector2.zero;
|
||||
|
||||
float wLeft = 0;
|
||||
float wRight = 0;
|
||||
|
||||
var position3D = movementPlane.ToWorld(position, elevation);
|
||||
for (int i = 0; i < wallBuffer.Count; i += 2) {
|
||||
Vector3 closest = VectorMath.ClosestPointOnSegment(wallBuffer[i], wallBuffer[i+1], position3D);
|
||||
float dist = (closest-position3D).sqrMagnitude;
|
||||
|
||||
if (dist > wallDist*wallDist) continue;
|
||||
|
||||
Vector2 tang = movementPlane.ToPlane(wallBuffer[i+1]-wallBuffer[i]).normalized;
|
||||
|
||||
// Using the fact that all walls are laid out clockwise (looking from inside the obstacle)
|
||||
// Then left and right (ish) can be figured out like this
|
||||
float dot = Vector2.Dot(directionToTarget, tang);
|
||||
float weight = 1 - System.Math.Max(0, (2*(dist / (wallDist*wallDist))-1));
|
||||
if (dot > 0) wRight = System.Math.Max(wRight, dot * weight);
|
||||
else wLeft = System.Math.Max(wLeft, -dot * weight);
|
||||
}
|
||||
|
||||
Vector2 normal = new Vector2(directionToTarget.y, -directionToTarget.x);
|
||||
return normal*(wRight-wLeft);
|
||||
}
|
||||
|
||||
/// <summary>Traverses an off-mesh link</summary>
|
||||
protected virtual IEnumerator TraverseSpecial (RichSpecial link) {
|
||||
traversingOffMeshLink = true;
|
||||
// The current path part is a special part, for example a link
|
||||
// Movement during this part of the path is handled by the TraverseSpecial coroutine
|
||||
velocity2D = Vector3.zero;
|
||||
var offMeshLinkCoroutine = onTraverseOffMeshLink != null? onTraverseOffMeshLink(link) : TraverseOffMeshLinkFallback(link);
|
||||
yield return StartCoroutine(offMeshLinkCoroutine);
|
||||
|
||||
// Off-mesh link traversal completed
|
||||
traversingOffMeshLink = false;
|
||||
NextPart();
|
||||
|
||||
// If a path completed during the time we traversed the special connection, we need to recalculate it
|
||||
if (delayUpdatePath) {
|
||||
delayUpdatePath = false;
|
||||
// TODO: What if canSearch is false? How do we notify other scripts that might be handling the path calculation that a new path needs to be calculated?
|
||||
if (canSearch) SearchPath();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fallback for traversing off-mesh links in case <see cref="onTraverseOffMeshLink"/> is not set.
|
||||
/// This will do a simple linear interpolation along the link.
|
||||
/// </summary>
|
||||
protected IEnumerator TraverseOffMeshLinkFallback (RichSpecial link) {
|
||||
float duration = maxSpeed > 0 ? Vector3.Distance(link.second.position, link.first.position) / maxSpeed : 1;
|
||||
float startTime = Time.time;
|
||||
|
||||
while (true) {
|
||||
var pos = Vector3.Lerp(link.first.position, link.second.position, Mathf.InverseLerp(startTime, startTime + duration, Time.time));
|
||||
if (updatePosition) tr.position = pos;
|
||||
else simulatedPosition = pos;
|
||||
|
||||
if (Time.time >= startTime + duration) break;
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
|
||||
protected static readonly Color GizmoColorPath = new Color(8.0f/255, 78.0f/255, 194.0f/255);
|
||||
|
||||
protected override void OnDrawGizmos () {
|
||||
base.OnDrawGizmos();
|
||||
|
||||
if (tr != null) {
|
||||
Gizmos.color = GizmoColorPath;
|
||||
Vector3 lastPosition = position;
|
||||
for (int i = 0; i < nextCorners.Count; lastPosition = nextCorners[i], i++) {
|
||||
Gizmos.DrawLine(lastPosition, nextCorners[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override int OnUpgradeSerializedData (int version, bool unityThread) {
|
||||
#pragma warning disable 618
|
||||
if (unityThread && animCompatibility != null) anim = animCompatibility;
|
||||
#pragma warning restore 618
|
||||
return base.OnUpgradeSerializedData(version, unityThread);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ce11ea984e202491d9271f53021d8b89
|
||||
timeCreated: 1491225739
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
896
BlueWater/Assets/AstarPathfindingProject/Core/AI/RichPath.cs
Normal file
896
BlueWater/Assets/AstarPathfindingProject/Core/AI/RichPath.cs
Normal file
@ -0,0 +1,896 @@
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
using Pathfinding.Util;
|
||||
|
||||
namespace Pathfinding {
|
||||
public class RichPath {
|
||||
int currentPart;
|
||||
readonly List<RichPathPart> parts = new List<RichPathPart>();
|
||||
|
||||
public Seeker seeker;
|
||||
|
||||
/// <summary>
|
||||
/// Transforms points from path space to world space.
|
||||
/// If null the identity transform will be used.
|
||||
///
|
||||
/// This is used when the world position of the agent does not match the
|
||||
/// corresponding position on the graph. This is the case in the example
|
||||
/// scene called 'Moving'.
|
||||
///
|
||||
/// See: <see cref="Pathfinding.Examples.LocalSpaceRichAI"/>
|
||||
/// </summary>
|
||||
public ITransform transform;
|
||||
|
||||
public RichPath () {
|
||||
Clear();
|
||||
}
|
||||
|
||||
public void Clear () {
|
||||
parts.Clear();
|
||||
currentPart = 0;
|
||||
Endpoint = new Vector3(float.PositiveInfinity, float.PositiveInfinity, float.PositiveInfinity);
|
||||
}
|
||||
|
||||
/// <summary>Use this for initialization.</summary>
|
||||
/// <param name="seeker">Optionally provide in order to take tag penalties into account. May be null if you do not use a Seeker\</param>
|
||||
/// <param name="path">Path to follow</param>
|
||||
/// <param name="mergePartEndpoints">If true, then adjacent parts that the path is split up in will
|
||||
/// try to use the same start/end points. For example when using a link on a navmesh graph
|
||||
/// Instead of first following the path to the center of the node where the link is and then
|
||||
/// follow the link, the path will be adjusted to go to the exact point where the link starts
|
||||
/// which usually makes more sense.</param>
|
||||
/// <param name="simplificationMode">The path can optionally be simplified. This can be a bit expensive for long paths.</param>
|
||||
public void Initialize (Seeker seeker, Path path, bool mergePartEndpoints, bool simplificationMode) {
|
||||
if (path.error) throw new System.ArgumentException("Path has an error");
|
||||
|
||||
List<GraphNode> nodes = path.path;
|
||||
if (nodes.Count == 0) throw new System.ArgumentException("Path traverses no nodes");
|
||||
|
||||
this.seeker = seeker;
|
||||
// Release objects back to object pool
|
||||
// Yeah, I know, it's casting... but this won't be called much
|
||||
for (int i = 0; i < parts.Count; i++) {
|
||||
var funnelPart = parts[i] as RichFunnel;
|
||||
var specialPart = parts[i] as RichSpecial;
|
||||
if (funnelPart != null) ObjectPool<RichFunnel>.Release(ref funnelPart);
|
||||
else if (specialPart != null) ObjectPool<RichSpecial>.Release(ref specialPart);
|
||||
}
|
||||
|
||||
Clear();
|
||||
|
||||
// Initialize new
|
||||
Endpoint = path.vectorPath[path.vectorPath.Count-1];
|
||||
|
||||
//Break path into parts
|
||||
for (int i = 0; i < nodes.Count; i++) {
|
||||
if (nodes[i] is TriangleMeshNode) {
|
||||
var graph = AstarData.GetGraph(nodes[i]) as NavmeshBase;
|
||||
if (graph == null) throw new System.Exception("Found a TriangleMeshNode that was not in a NavmeshBase graph");
|
||||
|
||||
RichFunnel f = ObjectPool<RichFunnel>.Claim().Initialize(this, graph);
|
||||
|
||||
f.funnelSimplification = simplificationMode;
|
||||
|
||||
int sIndex = i;
|
||||
uint currentGraphIndex = nodes[sIndex].GraphIndex;
|
||||
|
||||
|
||||
for (; i < nodes.Count; i++) {
|
||||
if (nodes[i].GraphIndex != currentGraphIndex && !(nodes[i] is NodeLink3Node)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
i--;
|
||||
|
||||
if (sIndex == 0) {
|
||||
f.exactStart = path.vectorPath[0];
|
||||
} else {
|
||||
f.exactStart = (Vector3)nodes[mergePartEndpoints ? sIndex-1 : sIndex].position;
|
||||
}
|
||||
|
||||
if (i == nodes.Count-1) {
|
||||
f.exactEnd = path.vectorPath[path.vectorPath.Count-1];
|
||||
} else {
|
||||
f.exactEnd = (Vector3)nodes[mergePartEndpoints ? i+1 : i].position;
|
||||
}
|
||||
|
||||
f.BuildFunnelCorridor(nodes, sIndex, i);
|
||||
|
||||
parts.Add(f);
|
||||
} else if (NodeLink2.GetNodeLink(nodes[i]) != null) {
|
||||
NodeLink2 nl = NodeLink2.GetNodeLink(nodes[i]);
|
||||
|
||||
int sIndex = i;
|
||||
uint currentGraphIndex = nodes[sIndex].GraphIndex;
|
||||
|
||||
for (i++; i < nodes.Count; i++) {
|
||||
if (nodes[i].GraphIndex != currentGraphIndex) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
i--;
|
||||
|
||||
if (i - sIndex > 1) {
|
||||
throw new System.Exception("NodeLink2 path length greater than two (2) nodes. " + (i - sIndex));
|
||||
} else if (i - sIndex == 0) {
|
||||
//Just continue, it might be the case that a NodeLink was the closest node
|
||||
continue;
|
||||
}
|
||||
|
||||
RichSpecial rps = ObjectPool<RichSpecial>.Claim().Initialize(nl, nodes[sIndex]);
|
||||
parts.Add(rps);
|
||||
} else if (!(nodes[i] is PointNode)) {
|
||||
// Some other graph type which we do not have support for
|
||||
throw new System.InvalidOperationException("The RichAI movment script can only be used on recast/navmesh graphs. A node of type " + nodes[i].GetType().Name + " was in the path.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Vector3 Endpoint { get; private set; }
|
||||
|
||||
/// <summary>True if we have completed (called NextPart for) the last part in the path</summary>
|
||||
public bool CompletedAllParts {
|
||||
get {
|
||||
return currentPart >= parts.Count;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>True if we are traversing the last part of the path</summary>
|
||||
public bool IsLastPart {
|
||||
get {
|
||||
return currentPart >= parts.Count - 1;
|
||||
}
|
||||
}
|
||||
|
||||
public void NextPart () {
|
||||
currentPart = Mathf.Min(currentPart + 1, parts.Count);
|
||||
}
|
||||
|
||||
public RichPathPart GetCurrentPart () {
|
||||
if (parts.Count == 0) return null;
|
||||
return currentPart < parts.Count ? parts[currentPart] : parts[parts.Count - 1];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Replaces the buffer with the remaining path.
|
||||
/// See: <see cref="Pathfinding.IAstarAI.GetRemainingPath"/>
|
||||
/// </summary>
|
||||
public void GetRemainingPath (List<Vector3> buffer, Vector3 currentPosition, out bool requiresRepath) {
|
||||
buffer.Clear();
|
||||
buffer.Add(currentPosition);
|
||||
requiresRepath = false;
|
||||
for (int i = currentPart; i < parts.Count; i++) {
|
||||
var part = parts[i];
|
||||
if (part is RichFunnel funnel) {
|
||||
bool lastCorner;
|
||||
if (i != 0) buffer.Add(funnel.exactStart);
|
||||
funnel.Update(i == 0 ? currentPosition : funnel.exactStart, buffer, int.MaxValue, out lastCorner, out requiresRepath);
|
||||
if (requiresRepath) {
|
||||
return;
|
||||
}
|
||||
} else if (part is RichSpecial link) {
|
||||
// By adding all points above the link will look like just a stright line, which is reasonable
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class RichPathPart : Pathfinding.Util.IAstarPooledObject {
|
||||
public abstract void OnEnterPool();
|
||||
}
|
||||
|
||||
public class RichFunnel : RichPathPart {
|
||||
readonly List<Vector3> left;
|
||||
readonly List<Vector3> right;
|
||||
List<TriangleMeshNode> nodes;
|
||||
public Vector3 exactStart;
|
||||
public Vector3 exactEnd;
|
||||
NavmeshBase graph;
|
||||
int currentNode;
|
||||
Vector3 currentPosition;
|
||||
int checkForDestroyedNodesCounter;
|
||||
RichPath path;
|
||||
int[] triBuffer = new int[3];
|
||||
|
||||
/// <summary>Post process the funnel corridor or not</summary>
|
||||
public bool funnelSimplification = true;
|
||||
|
||||
public RichFunnel () {
|
||||
left = Pathfinding.Util.ListPool<Vector3>.Claim();
|
||||
right = Pathfinding.Util.ListPool<Vector3>.Claim();
|
||||
nodes = new List<TriangleMeshNode>();
|
||||
this.graph = null;
|
||||
}
|
||||
|
||||
/// <summary>Works like a constructor, but can be used even for pooled objects. Returns this for easy chaining</summary>
|
||||
public RichFunnel Initialize (RichPath path, NavmeshBase graph) {
|
||||
if (graph == null) throw new System.ArgumentNullException("graph");
|
||||
if (this.graph != null) throw new System.InvalidOperationException("Trying to initialize an already initialized object. " + graph);
|
||||
|
||||
this.graph = graph;
|
||||
this.path = path;
|
||||
return this;
|
||||
}
|
||||
|
||||
public override void OnEnterPool () {
|
||||
left.Clear();
|
||||
right.Clear();
|
||||
nodes.Clear();
|
||||
graph = null;
|
||||
currentNode = 0;
|
||||
checkForDestroyedNodesCounter = 0;
|
||||
}
|
||||
|
||||
public TriangleMeshNode CurrentNode {
|
||||
get {
|
||||
var node = nodes[currentNode];
|
||||
if (!node.Destroyed) {
|
||||
return node;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Build a funnel corridor from a node list slice.
|
||||
/// The nodes are assumed to be of type TriangleMeshNode.
|
||||
/// </summary>
|
||||
/// <param name="nodes">Nodes to build the funnel corridor from</param>
|
||||
/// <param name="start">Start index in the nodes list</param>
|
||||
/// <param name="end">End index in the nodes list, this index is inclusive</param>
|
||||
public void BuildFunnelCorridor (List<GraphNode> nodes, int start, int end) {
|
||||
//Make sure start and end points are on the correct nodes
|
||||
exactStart = (nodes[start] as MeshNode).ClosestPointOnNode(exactStart);
|
||||
exactEnd = (nodes[end] as MeshNode).ClosestPointOnNode(exactEnd);
|
||||
|
||||
left.Clear();
|
||||
right.Clear();
|
||||
left.Add(exactStart);
|
||||
right.Add(exactStart);
|
||||
|
||||
this.nodes.Clear();
|
||||
|
||||
if (funnelSimplification) {
|
||||
List<GraphNode> tmp = Pathfinding.Util.ListPool<GraphNode>.Claim(end-start);
|
||||
|
||||
SimplifyPath(graph, nodes, start, end, tmp, exactStart, exactEnd);
|
||||
|
||||
if (this.nodes.Capacity < tmp.Count) this.nodes.Capacity = tmp.Count;
|
||||
|
||||
for (int i = 0; i < tmp.Count; i++) {
|
||||
//Guaranteed to be TriangleMeshNodes since they are all in the same graph
|
||||
var node = tmp[i] as TriangleMeshNode;
|
||||
if (node != null) this.nodes.Add(node);
|
||||
}
|
||||
|
||||
Pathfinding.Util.ListPool<GraphNode>.Release(ref tmp);
|
||||
} else {
|
||||
if (this.nodes.Capacity < end-start) this.nodes.Capacity = (end-start);
|
||||
for (int i = start; i <= end; i++) {
|
||||
//Guaranteed to be TriangleMeshNodes since they are all in the same graph
|
||||
var node = nodes[i] as TriangleMeshNode;
|
||||
if (node != null) this.nodes.Add(node);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < this.nodes.Count-1; i++) {
|
||||
/// <summary>TODO: should use return value in future versions</summary>
|
||||
this.nodes[i].GetPortal(this.nodes[i+1], left, right, false);
|
||||
}
|
||||
|
||||
left.Add(exactEnd);
|
||||
right.Add(exactEnd);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Simplifies a funnel path using linecasting.
|
||||
/// Running time is roughly O(n^2 log n) in the worst case (where n = end-start)
|
||||
/// Actually it depends on how the graph looks, so in theory the actual upper limit on the worst case running time is O(n*m log n) (where n = end-start and m = nodes in the graph)
|
||||
/// but O(n^2 log n) is a much more realistic worst case limit.
|
||||
///
|
||||
/// Requires <see cref="graph"/> to implement IRaycastableGraph
|
||||
/// </summary>
|
||||
void SimplifyPath (IRaycastableGraph graph, List<GraphNode> nodes, int start, int end, List<GraphNode> result, Vector3 startPoint, Vector3 endPoint) {
|
||||
if (graph == null) throw new System.ArgumentNullException("graph");
|
||||
|
||||
if (start > end) {
|
||||
throw new System.ArgumentException("start >= end");
|
||||
}
|
||||
|
||||
// Do a straight line of sight check to see if the path can be simplified to a single line
|
||||
{
|
||||
GraphHitInfo hit;
|
||||
if (!graph.Linecast(startPoint, endPoint, out hit) && hit.node == nodes[end]) {
|
||||
graph.Linecast(startPoint, endPoint, out hit, result);
|
||||
|
||||
long penaltySum = 0;
|
||||
long penaltySum2 = 0;
|
||||
for (int i = start; i <= end; i++) {
|
||||
penaltySum += nodes[i].Penalty + (path.seeker != null ? path.seeker.tagPenalties[nodes[i].Tag] : 0);
|
||||
}
|
||||
|
||||
for (int i = 0; i < result.Count; i++) {
|
||||
penaltySum2 += result[i].Penalty + (path.seeker != null ? path.seeker.tagPenalties[result[i].Tag] : 0);
|
||||
}
|
||||
|
||||
// Allow 40% more penalty on average per node
|
||||
if ((penaltySum*1.4*result.Count) < (penaltySum2*(end-start+1))) {
|
||||
// The straight line penalties are much higher than the original path.
|
||||
// Revert the simplification
|
||||
result.Clear();
|
||||
} else {
|
||||
// The straight line simplification looks good.
|
||||
// We are done here.
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int ostart = start;
|
||||
|
||||
int count = 0;
|
||||
while (true) {
|
||||
if (count++ > 1000) {
|
||||
Debug.LogError("Was the path really long or have we got cought in an infinite loop?");
|
||||
break;
|
||||
}
|
||||
|
||||
if (start == end) {
|
||||
result.Add(nodes[end]);
|
||||
return;
|
||||
}
|
||||
|
||||
int resCount = result.Count;
|
||||
|
||||
// Run a binary search to find the furthest node that we have a clear line of sight to
|
||||
int mx = end+1;
|
||||
int mn = start+1;
|
||||
bool anySucceded = false;
|
||||
while (mx > mn+1) {
|
||||
int mid = (mx+mn)/2;
|
||||
|
||||
GraphHitInfo hit;
|
||||
Vector3 sp = start == ostart ? startPoint : (Vector3)nodes[start].position;
|
||||
Vector3 ep = mid == end ? endPoint : (Vector3)nodes[mid].position;
|
||||
|
||||
// Check if there is an obstacle between these points, or if there is no obstacle, but we didn't end up at the right node.
|
||||
// The second case can happen for example in buildings with multiple floors.
|
||||
if (graph.Linecast(sp, ep, out hit) || hit.node != nodes[mid]) {
|
||||
mx = mid;
|
||||
} else {
|
||||
anySucceded = true;
|
||||
mn = mid;
|
||||
}
|
||||
}
|
||||
|
||||
if (!anySucceded) {
|
||||
result.Add(nodes[start]);
|
||||
|
||||
// It is guaranteed that mn = start+1
|
||||
start = mn;
|
||||
} else {
|
||||
// Replace a part of the path with the straight path to the furthest node we had line of sight to.
|
||||
// Need to redo the linecast to get the trace (i.e. list of nodes along the line of sight).
|
||||
GraphHitInfo hit;
|
||||
Vector3 sp = start == ostart ? startPoint : (Vector3)nodes[start].position;
|
||||
Vector3 ep = mn == end ? endPoint : (Vector3)nodes[mn].position;
|
||||
graph.Linecast(sp, ep, out hit, result);
|
||||
|
||||
long penaltySum = 0;
|
||||
long penaltySum2 = 0;
|
||||
for (int i = start; i <= mn; i++) {
|
||||
penaltySum += nodes[i].Penalty + (path.seeker != null ? path.seeker.tagPenalties[nodes[i].Tag] : 0);
|
||||
}
|
||||
|
||||
for (int i = resCount; i < result.Count; i++) {
|
||||
penaltySum2 += result[i].Penalty + (path.seeker != null ? path.seeker.tagPenalties[result[i].Tag] : 0);
|
||||
}
|
||||
|
||||
// Allow 40% more penalty on average per node
|
||||
if ((penaltySum*1.4*(result.Count-resCount)) < (penaltySum2*(mn-start+1)) || result[result.Count-1] != nodes[mn]) {
|
||||
//Debug.DrawLine ((Vector3)nodes[start].Position, (Vector3)nodes[mn].Position, Color.red);
|
||||
// Linecast hit the wrong node
|
||||
result.RemoveRange(resCount, result.Count-resCount);
|
||||
|
||||
result.Add(nodes[start]);
|
||||
//Debug.Break();
|
||||
start = start+1;
|
||||
} else {
|
||||
//Debug.DrawLine ((Vector3)nodes[start].Position, (Vector3)nodes[mn].Position, Color.green);
|
||||
//Remove nodes[end]
|
||||
result.RemoveAt(result.Count-1);
|
||||
start = mn;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Split funnel at node index splitIndex and throw the nodes up to that point away and replace with prefix.
|
||||
/// Used when the AI has happened to get sidetracked and entered a node outside the funnel.
|
||||
/// </summary>
|
||||
void UpdateFunnelCorridor (int splitIndex, List<TriangleMeshNode> prefix) {
|
||||
nodes.RemoveRange(0, splitIndex);
|
||||
nodes.InsertRange(0, prefix);
|
||||
|
||||
left.Clear();
|
||||
right.Clear();
|
||||
left.Add(exactStart);
|
||||
right.Add(exactStart);
|
||||
|
||||
for (int i = 0; i < nodes.Count-1; i++) {
|
||||
//NOTE should use return value in future versions
|
||||
nodes[i].GetPortal(nodes[i+1], left, right, false);
|
||||
}
|
||||
|
||||
left.Add(exactEnd);
|
||||
right.Add(exactEnd);
|
||||
}
|
||||
|
||||
/// <summary>True if any node in the path is destroyed</summary>
|
||||
bool CheckForDestroyedNodes () {
|
||||
// Loop through all nodes and check if they are destroyed
|
||||
// If so, we really need a recalculation of our path quickly
|
||||
// since there might be an obstacle blocking our path after
|
||||
// a graph update or something similar
|
||||
for (int i = 0, t = nodes.Count; i < t; i++) {
|
||||
if (nodes[i].Destroyed) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Approximate distance (as the crow flies) to the endpoint of this path part.
|
||||
/// See: <see cref="exactEnd"/>
|
||||
/// </summary>
|
||||
public float DistanceToEndOfPath {
|
||||
get {
|
||||
var currentNode = CurrentNode;
|
||||
Vector3 closestOnNode = currentNode != null? currentNode.ClosestPointOnNode(currentPosition) : currentPosition;
|
||||
return (exactEnd - closestOnNode).magnitude;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clamps the position to the navmesh and repairs the path if the agent has moved slightly outside it.
|
||||
/// You should not call this method with anything other than the agent's position.
|
||||
/// </summary>
|
||||
public Vector3 ClampToNavmesh (Vector3 position) {
|
||||
if (path.transform != null) position = path.transform.InverseTransform(position);
|
||||
ClampToNavmeshInternal(ref position);
|
||||
if (path.transform != null) position = path.transform.Transform(position);
|
||||
return position;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Find the next points to move towards and clamp the position to the navmesh.
|
||||
///
|
||||
/// Returns: The position of the agent clamped to make sure it is inside the navmesh.
|
||||
/// </summary>
|
||||
/// <param name="position">The position of the agent.</param>
|
||||
/// <param name="buffer">Will be filled with up to numCorners points which are the next points in the path towards the target.</param>
|
||||
/// <param name="numCorners">See buffer.</param>
|
||||
/// <param name="lastCorner">True if the buffer contains the end point of the path.</param>
|
||||
/// <param name="requiresRepath">True if nodes along the path have been destroyed and a path recalculation is necessary.</param>
|
||||
public Vector3 Update (Vector3 position, List<Vector3> buffer, int numCorners, out bool lastCorner, out bool requiresRepath) {
|
||||
if (path.transform != null) position = path.transform.InverseTransform(position);
|
||||
|
||||
lastCorner = false;
|
||||
requiresRepath = false;
|
||||
|
||||
// Only check for destroyed nodes every 10 frames
|
||||
if (checkForDestroyedNodesCounter >= 10) {
|
||||
checkForDestroyedNodesCounter = 0;
|
||||
requiresRepath |= CheckForDestroyedNodes();
|
||||
} else {
|
||||
checkForDestroyedNodesCounter++;
|
||||
}
|
||||
|
||||
bool nodesDestroyed = ClampToNavmeshInternal(ref position);
|
||||
|
||||
currentPosition = position;
|
||||
|
||||
if (nodesDestroyed) {
|
||||
// Some nodes on the path have been destroyed
|
||||
// we need to recalculate the path immediately
|
||||
requiresRepath = true;
|
||||
lastCorner = false;
|
||||
buffer.Add(position);
|
||||
} else if (!FindNextCorners(position, currentNode, buffer, numCorners, out lastCorner)) {
|
||||
Debug.LogError("Failed to find next corners in the path");
|
||||
buffer.Add(position);
|
||||
}
|
||||
|
||||
if (path.transform != null) {
|
||||
for (int i = 0; i < buffer.Count; i++) {
|
||||
buffer[i] = path.transform.Transform(buffer[i]);
|
||||
}
|
||||
|
||||
position = path.transform.Transform(position);
|
||||
}
|
||||
|
||||
return position;
|
||||
}
|
||||
|
||||
/// <summary>Cached object to avoid unnecessary allocations</summary>
|
||||
static Queue<TriangleMeshNode> navmeshClampQueue = new Queue<TriangleMeshNode>();
|
||||
/// <summary>Cached object to avoid unnecessary allocations</summary>
|
||||
static List<TriangleMeshNode> navmeshClampList = new List<TriangleMeshNode>();
|
||||
/// <summary>Cached object to avoid unnecessary allocations</summary>
|
||||
static Dictionary<TriangleMeshNode, TriangleMeshNode> navmeshClampDict = new Dictionary<TriangleMeshNode, TriangleMeshNode>();
|
||||
|
||||
/// <summary>
|
||||
/// Searches for the node the agent is inside.
|
||||
/// This will also clamp the position to the navmesh
|
||||
/// and repair the funnel cooridor if the agent moves slightly outside it.
|
||||
///
|
||||
/// Returns: True if nodes along the path have been destroyed so that a path recalculation is required
|
||||
/// </summary>
|
||||
bool ClampToNavmeshInternal (ref Vector3 position) {
|
||||
var previousNode = nodes[currentNode];
|
||||
|
||||
if (previousNode.Destroyed) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check if we are in the same node as we were in during the last frame and otherwise do a more extensive search
|
||||
if (previousNode.ContainsPoint(position)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// This part of the code is relatively seldom called
|
||||
// Most of the time we are still on the same node as during the previous frame
|
||||
|
||||
var que = navmeshClampQueue;
|
||||
var allVisited = navmeshClampList;
|
||||
var parent = navmeshClampDict;
|
||||
previousNode.TemporaryFlag1 = true;
|
||||
parent[previousNode] = null;
|
||||
que.Enqueue(previousNode);
|
||||
allVisited.Add(previousNode);
|
||||
|
||||
float bestDistance = float.PositiveInfinity;
|
||||
Vector3 bestPoint = position;
|
||||
TriangleMeshNode bestNode = null;
|
||||
|
||||
while (que.Count > 0) {
|
||||
var node = que.Dequeue();
|
||||
|
||||
// Snap to the closest point in XZ space (keep the Y coordinate)
|
||||
// If we would have snapped to the closest point in 3D space, the agent
|
||||
// might slow down when traversing slopes
|
||||
var closest = node.ClosestPointOnNodeXZ(position);
|
||||
var dist = VectorMath.MagnitudeXZ(closest - position);
|
||||
|
||||
// Check if this node is any closer than the previous best node.
|
||||
// Allow for a small margin to both avoid floating point errors and to allow
|
||||
// moving past very small local minima.
|
||||
if (dist <= bestDistance * 1.05f + 0.001f) {
|
||||
if (dist < bestDistance) {
|
||||
bestDistance = dist;
|
||||
bestPoint = closest;
|
||||
bestNode = node;
|
||||
}
|
||||
|
||||
for (int i = 0; i < node.connections.Length; i++) {
|
||||
var neighbour = node.connections[i].node as TriangleMeshNode;
|
||||
if (neighbour != null && !neighbour.TemporaryFlag1) {
|
||||
neighbour.TemporaryFlag1 = true;
|
||||
parent[neighbour] = node;
|
||||
que.Enqueue(neighbour);
|
||||
allVisited.Add(neighbour);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < allVisited.Count; i++) allVisited[i].TemporaryFlag1 = false;
|
||||
allVisited.ClearFast();
|
||||
|
||||
var closestNodeInPath = nodes.IndexOf(bestNode);
|
||||
|
||||
// Move the x and z coordinates of the chararacter but not the y coordinate
|
||||
// because the navmesh surface may not line up with the ground
|
||||
position.x = bestPoint.x;
|
||||
position.z = bestPoint.z;
|
||||
|
||||
// Check if the closest node
|
||||
// was on the path already or if we need to adjust it
|
||||
if (closestNodeInPath == -1) {
|
||||
// Reuse this list, because why not.
|
||||
var prefix = navmeshClampList;
|
||||
|
||||
while (closestNodeInPath == -1) {
|
||||
prefix.Add(bestNode);
|
||||
bestNode = parent[bestNode];
|
||||
closestNodeInPath = nodes.IndexOf(bestNode);
|
||||
}
|
||||
|
||||
// We have found a node containing the position, but it is outside the funnel
|
||||
// Recalculate the funnel to include this node
|
||||
exactStart = position;
|
||||
UpdateFunnelCorridor(closestNodeInPath, prefix);
|
||||
|
||||
prefix.ClearFast();
|
||||
|
||||
// Restart from the first node in the updated path
|
||||
currentNode = 0;
|
||||
} else {
|
||||
currentNode = closestNodeInPath;
|
||||
}
|
||||
|
||||
parent.Clear();
|
||||
// Do a quick check to see if the next node in the path has been destroyed
|
||||
// If that is the case then we should plan a new path immediately
|
||||
return currentNode + 1 < nodes.Count && nodes[currentNode+1].Destroyed;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fill wallBuffer with all navmesh wall segments close to the current position.
|
||||
/// A wall segment is a node edge which is not shared by any other neighbour node, i.e an outer edge on the navmesh.
|
||||
/// </summary>
|
||||
public void FindWalls (List<Vector3> wallBuffer, float range) {
|
||||
FindWalls(currentNode, wallBuffer, currentPosition, range);
|
||||
}
|
||||
|
||||
void FindWalls (int nodeIndex, List<Vector3> wallBuffer, Vector3 position, float range) {
|
||||
if (range <= 0) return;
|
||||
|
||||
bool negAbort = false;
|
||||
bool posAbort = false;
|
||||
|
||||
range *= range;
|
||||
|
||||
position.y = 0;
|
||||
//Looping as 0,-1,1,-2,2,-3,3,-4,4 etc. Avoids code duplication by keeping it to one loop instead of two
|
||||
for (int i = 0; !negAbort || !posAbort; i = i < 0 ? -i : -i-1) {
|
||||
if (i < 0 && negAbort) continue;
|
||||
if (i > 0 && posAbort) continue;
|
||||
|
||||
if (i < 0 && nodeIndex+i < 0) {
|
||||
negAbort = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (i > 0 && nodeIndex+i >= nodes.Count) {
|
||||
posAbort = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
TriangleMeshNode prev = nodeIndex+i-1 < 0 ? null : nodes[nodeIndex+i-1];
|
||||
TriangleMeshNode node = nodes[nodeIndex+i];
|
||||
TriangleMeshNode next = nodeIndex+i+1 >= nodes.Count ? null : nodes[nodeIndex+i+1];
|
||||
|
||||
if (node.Destroyed) {
|
||||
break;
|
||||
}
|
||||
|
||||
if ((node.ClosestPointOnNodeXZ(position)-position).sqrMagnitude > range) {
|
||||
if (i < 0) negAbort = true;
|
||||
else posAbort = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
for (int j = 0; j < 3; j++) triBuffer[j] = 0;
|
||||
|
||||
for (int j = 0; j < node.connections.Length; j++) {
|
||||
var other = node.connections[j].node as TriangleMeshNode;
|
||||
if (other == null) continue;
|
||||
|
||||
int va = -1;
|
||||
for (int a = 0; a < 3; a++) {
|
||||
for (int b = 0; b < 3; b++) {
|
||||
if (node.GetVertex(a) == other.GetVertex((b+1) % 3) && node.GetVertex((a+1) % 3) == other.GetVertex(b)) {
|
||||
va = a;
|
||||
a = 3;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (va == -1) {
|
||||
//No direct connection
|
||||
} else {
|
||||
triBuffer[va] = other == prev || other == next ? 2 : 1;
|
||||
}
|
||||
}
|
||||
|
||||
for (int j = 0; j < 3; j++) {
|
||||
//Tribuffer values
|
||||
// 0 : Navmesh border, outer edge
|
||||
// 1 : Inner edge, to node inside funnel
|
||||
// 2 : Inner edge, to node outside funnel
|
||||
if (triBuffer[j] == 0) {
|
||||
//Add edge to list of walls
|
||||
wallBuffer.Add((Vector3)node.GetVertex(j));
|
||||
wallBuffer.Add((Vector3)node.GetVertex((j+1) % 3));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (path.transform != null) {
|
||||
for (int i = 0; i < wallBuffer.Count; i++) {
|
||||
wallBuffer[i] = path.transform.Transform(wallBuffer[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool FindNextCorners (Vector3 origin, int startIndex, List<Vector3> funnelPath, int numCorners, out bool lastCorner) {
|
||||
lastCorner = false;
|
||||
|
||||
if (left == null) throw new System.Exception("left list is null");
|
||||
if (right == null) throw new System.Exception("right list is null");
|
||||
if (funnelPath == null) throw new System.ArgumentNullException("funnelPath");
|
||||
|
||||
if (left.Count != right.Count) throw new System.ArgumentException("left and right lists must have equal length");
|
||||
|
||||
int diagonalCount = left.Count;
|
||||
|
||||
if (diagonalCount == 0) throw new System.ArgumentException("no diagonals");
|
||||
|
||||
if (diagonalCount-startIndex < 3) {
|
||||
//Direct path
|
||||
funnelPath.Add(left[diagonalCount-1]);
|
||||
lastCorner = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
#if ASTARDEBUG
|
||||
for (int i = startIndex; i < left.Count-1; i++) {
|
||||
Debug.DrawLine(left[i], left[i+1], Color.red);
|
||||
Debug.DrawLine(right[i], right[i+1], Color.magenta);
|
||||
Debug.DrawRay(right[i], Vector3.up, Color.magenta);
|
||||
}
|
||||
for (int i = 0; i < left.Count; i++) {
|
||||
Debug.DrawLine(right[i], left[i], Color.cyan);
|
||||
}
|
||||
#endif
|
||||
|
||||
//Remove identical vertices
|
||||
while (left[startIndex+1] == left[startIndex+2] && right[startIndex+1] == right[startIndex+2]) {
|
||||
//System.Console.WriteLine ("Removing identical left and right");
|
||||
//left.RemoveAt (1);
|
||||
//right.RemoveAt (1);
|
||||
startIndex++;
|
||||
|
||||
if (diagonalCount-startIndex <= 3) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Vector3 swPoint = left[startIndex+2];
|
||||
if (swPoint == left[startIndex+1]) {
|
||||
swPoint = right[startIndex+2];
|
||||
}
|
||||
|
||||
|
||||
//Test
|
||||
while (VectorMath.IsColinearXZ(origin, left[startIndex+1], right[startIndex+1]) || VectorMath.RightOrColinearXZ(left[startIndex+1], right[startIndex+1], swPoint) == VectorMath.RightOrColinearXZ(left[startIndex+1], right[startIndex+1], origin)) {
|
||||
#if ASTARDEBUG
|
||||
Debug.DrawLine(left[startIndex+1], right[startIndex+1], new Color(0, 0, 0, 0.5F));
|
||||
Debug.DrawLine(origin, swPoint, new Color(0, 0, 0, 0.5F));
|
||||
#endif
|
||||
//left.RemoveAt (1);
|
||||
//right.RemoveAt (1);
|
||||
startIndex++;
|
||||
|
||||
if (diagonalCount-startIndex < 3) {
|
||||
//Debug.Log ("#2 " + left.Count + " - " + startIndex + " = " + (left.Count-startIndex));
|
||||
//Direct path
|
||||
funnelPath.Add(left[diagonalCount-1]);
|
||||
lastCorner = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
swPoint = left[startIndex+2];
|
||||
if (swPoint == left[startIndex+1]) {
|
||||
swPoint = right[startIndex+2];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//funnelPath.Add (origin);
|
||||
|
||||
Vector3 portalApex = origin;
|
||||
Vector3 portalLeft = left[startIndex+1];
|
||||
Vector3 portalRight = right[startIndex+1];
|
||||
|
||||
int apexIndex = startIndex+0;
|
||||
int rightIndex = startIndex+1;
|
||||
int leftIndex = startIndex+1;
|
||||
|
||||
for (int i = startIndex+2; i < diagonalCount; i++) {
|
||||
if (funnelPath.Count >= numCorners) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (funnelPath.Count > 2000) {
|
||||
Debug.LogWarning("Avoiding infinite loop. Remove this check if you have this long paths.");
|
||||
break;
|
||||
}
|
||||
|
||||
Vector3 pLeft = left[i];
|
||||
Vector3 pRight = right[i];
|
||||
|
||||
/*Debug.DrawLine (portalApex,portalLeft,Color.red);
|
||||
* Debug.DrawLine (portalApex,portalRight,Color.yellow);
|
||||
* Debug.DrawLine (portalApex,left,Color.cyan);
|
||||
* Debug.DrawLine (portalApex,right,Color.cyan);*/
|
||||
|
||||
if (VectorMath.SignedTriangleAreaTimes2XZ(portalApex, portalRight, pRight) >= 0) {
|
||||
if (portalApex == portalRight || VectorMath.SignedTriangleAreaTimes2XZ(portalApex, portalLeft, pRight) <= 0) {
|
||||
portalRight = pRight;
|
||||
rightIndex = i;
|
||||
} else {
|
||||
funnelPath.Add(portalLeft);
|
||||
portalApex = portalLeft;
|
||||
apexIndex = leftIndex;
|
||||
|
||||
portalLeft = portalApex;
|
||||
portalRight = portalApex;
|
||||
|
||||
leftIndex = apexIndex;
|
||||
rightIndex = apexIndex;
|
||||
|
||||
i = apexIndex;
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (VectorMath.SignedTriangleAreaTimes2XZ(portalApex, portalLeft, pLeft) <= 0) {
|
||||
if (portalApex == portalLeft || VectorMath.SignedTriangleAreaTimes2XZ(portalApex, portalRight, pLeft) >= 0) {
|
||||
portalLeft = pLeft;
|
||||
leftIndex = i;
|
||||
} else {
|
||||
funnelPath.Add(portalRight);
|
||||
portalApex = portalRight;
|
||||
apexIndex = rightIndex;
|
||||
|
||||
portalLeft = portalApex;
|
||||
portalRight = portalApex;
|
||||
|
||||
leftIndex = apexIndex;
|
||||
rightIndex = apexIndex;
|
||||
|
||||
i = apexIndex;
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lastCorner = true;
|
||||
funnelPath.Add(left[diagonalCount-1]);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public class RichSpecial : RichPathPart {
|
||||
public NodeLink2 nodeLink;
|
||||
public Transform first;
|
||||
public Transform second;
|
||||
public bool reverse;
|
||||
|
||||
public override void OnEnterPool () {
|
||||
nodeLink = null;
|
||||
}
|
||||
|
||||
/// <summary>Works like a constructor, but can be used even for pooled objects. Returns this for easy chaining</summary>
|
||||
public RichSpecial Initialize (NodeLink2 nodeLink, GraphNode first) {
|
||||
this.nodeLink = nodeLink;
|
||||
if (first == nodeLink.startNode) {
|
||||
this.first = nodeLink.StartTransform;
|
||||
this.second = nodeLink.EndTransform;
|
||||
reverse = false;
|
||||
} else {
|
||||
this.first = nodeLink.EndTransform;
|
||||
this.second = nodeLink.StartTransform;
|
||||
reverse = true;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6865b0d3859fe4641ad0839b829e00d2
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
599
BlueWater/Assets/AstarPathfindingProject/Core/AI/Seeker.cs
Normal file
599
BlueWater/Assets/AstarPathfindingProject/Core/AI/Seeker.cs
Normal file
@ -0,0 +1,599 @@
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine.Profiling;
|
||||
|
||||
namespace Pathfinding {
|
||||
/// <summary>
|
||||
/// Handles path calls for a single unit.
|
||||
///
|
||||
/// This is a component which is meant to be attached to a single unit (AI, Robot, Player, whatever) to handle its pathfinding calls.
|
||||
/// It also handles post-processing of paths using modifiers.
|
||||
///
|
||||
/// [Open online documentation to see images]
|
||||
///
|
||||
/// See: calling-pathfinding (view in online documentation for working links)
|
||||
/// See: modifiers (view in online documentation for working links)
|
||||
/// </summary>
|
||||
[AddComponentMenu("Pathfinding/Seeker")]
|
||||
[HelpURL("http://arongranberg.com/astar/documentation/stable/class_pathfinding_1_1_seeker.php")]
|
||||
public class Seeker : VersionedMonoBehaviour {
|
||||
/// <summary>
|
||||
/// Enables drawing of the last calculated path using Gizmos.
|
||||
/// The path will show up in green.
|
||||
///
|
||||
/// See: OnDrawGizmos
|
||||
/// </summary>
|
||||
public bool drawGizmos = true;
|
||||
|
||||
/// <summary>
|
||||
/// Enables drawing of the non-postprocessed path using Gizmos.
|
||||
/// The path will show up in orange.
|
||||
///
|
||||
/// Requires that <see cref="drawGizmos"/> is true.
|
||||
///
|
||||
/// This will show the path before any post processing such as smoothing is applied.
|
||||
///
|
||||
/// See: drawGizmos
|
||||
/// See: OnDrawGizmos
|
||||
/// </summary>
|
||||
public bool detailedGizmos;
|
||||
|
||||
/// <summary>Path modifier which tweaks the start and end points of a path</summary>
|
||||
[HideInInspector]
|
||||
public StartEndModifier startEndModifier = new StartEndModifier();
|
||||
|
||||
/// <summary>
|
||||
/// The tags which the Seeker can traverse.
|
||||
///
|
||||
/// Note: This field is a bitmask.
|
||||
/// See: bitmasks (view in online documentation for working links)
|
||||
/// </summary>
|
||||
[HideInInspector]
|
||||
public int traversableTags = -1;
|
||||
|
||||
/// <summary>
|
||||
/// Penalties for each tag.
|
||||
/// Tag 0 which is the default tag, will have added a penalty of tagPenalties[0].
|
||||
/// These should only be positive values since the A* algorithm cannot handle negative penalties.
|
||||
///
|
||||
/// Note: This array should always have a length of 32 otherwise the system will ignore it.
|
||||
///
|
||||
/// See: Pathfinding.Path.tagPenalties
|
||||
/// </summary>
|
||||
[HideInInspector]
|
||||
public int[] tagPenalties = new int[32];
|
||||
|
||||
/// <summary>
|
||||
/// Graphs that this Seeker can use.
|
||||
/// This field determines which graphs will be considered when searching for the start and end nodes of a path.
|
||||
/// It is useful in numerous situations, for example if you want to make one graph for small units and one graph for large units.
|
||||
///
|
||||
/// This is a bitmask so if you for example want to make the agent only use graph index 3 then you can set this to:
|
||||
/// <code> seeker.graphMask = 1 << 3; </code>
|
||||
///
|
||||
/// See: bitmasks (view in online documentation for working links)
|
||||
///
|
||||
/// Note that this field only stores which graph indices that are allowed. This means that if the graphs change their ordering
|
||||
/// then this mask may no longer be correct.
|
||||
///
|
||||
/// If you know the name of the graph you can use the <see cref="Pathfinding.GraphMask.FromGraphName"/> method:
|
||||
/// <code>
|
||||
/// GraphMask mask1 = GraphMask.FromGraphName("My Grid Graph");
|
||||
/// GraphMask mask2 = GraphMask.FromGraphName("My Other Grid Graph");
|
||||
///
|
||||
/// NNConstraint nn = NNConstraint.Default;
|
||||
///
|
||||
/// nn.graphMask = mask1 | mask2;
|
||||
///
|
||||
/// // Find the node closest to somePoint which is either in 'My Grid Graph' OR in 'My Other Grid Graph'
|
||||
/// var info = AstarPath.active.GetNearest(somePoint, nn);
|
||||
/// </code>
|
||||
///
|
||||
/// Some overloads of the <see cref="StartPath"/> methods take a graphMask parameter. If those overloads are used then they
|
||||
/// will override the graph mask for that path request.
|
||||
///
|
||||
/// [Open online documentation to see images]
|
||||
///
|
||||
/// See: multiple-agent-types (view in online documentation for working links)
|
||||
/// </summary>
|
||||
[HideInInspector]
|
||||
public GraphMask graphMask = GraphMask.everything;
|
||||
|
||||
/// <summary>Used for serialization backwards compatibility</summary>
|
||||
[UnityEngine.Serialization.FormerlySerializedAs("graphMask")]
|
||||
int graphMaskCompatibility = -1;
|
||||
|
||||
/// <summary>
|
||||
/// Callback for when a path is completed.
|
||||
/// Movement scripts should register to this delegate.
|
||||
/// A temporary callback can also be set when calling StartPath, but that delegate will only be called for that path
|
||||
/// </summary>
|
||||
public OnPathDelegate pathCallback;
|
||||
|
||||
/// <summary>Called before pathfinding is started</summary>
|
||||
public OnPathDelegate preProcessPath;
|
||||
|
||||
/// <summary>Called after a path has been calculated, right before modifiers are executed.</summary>
|
||||
public OnPathDelegate postProcessPath;
|
||||
|
||||
/// <summary>Used for drawing gizmos</summary>
|
||||
[System.NonSerialized]
|
||||
List<Vector3> lastCompletedVectorPath;
|
||||
|
||||
/// <summary>Used for drawing gizmos</summary>
|
||||
[System.NonSerialized]
|
||||
List<GraphNode> lastCompletedNodePath;
|
||||
|
||||
/// <summary>The current path</summary>
|
||||
[System.NonSerialized]
|
||||
protected Path path;
|
||||
|
||||
/// <summary>Previous path. Used to draw gizmos</summary>
|
||||
[System.NonSerialized]
|
||||
private Path prevPath;
|
||||
|
||||
/// <summary>Cached delegate to avoid allocating one every time a path is started</summary>
|
||||
private readonly OnPathDelegate onPathDelegate;
|
||||
/// <summary>Cached delegate to avoid allocating one every time a path is started</summary>
|
||||
private readonly OnPathDelegate onPartialPathDelegate;
|
||||
|
||||
/// <summary>Temporary callback only called for the current path. This value is set by the StartPath functions</summary>
|
||||
private OnPathDelegate tmpPathCallback;
|
||||
|
||||
/// <summary>The path ID of the last path queried</summary>
|
||||
protected uint lastPathID;
|
||||
|
||||
/// <summary>Internal list of all modifiers</summary>
|
||||
readonly List<IPathModifier> modifiers = new List<IPathModifier>();
|
||||
|
||||
public enum ModifierPass {
|
||||
PreProcess,
|
||||
// An obsolete item occupied index 1 previously
|
||||
PostProcess = 2,
|
||||
}
|
||||
|
||||
public Seeker () {
|
||||
onPathDelegate = OnPathComplete;
|
||||
onPartialPathDelegate = OnPartialPathComplete;
|
||||
}
|
||||
|
||||
/// <summary>Initializes a few variables</summary>
|
||||
protected override void Awake () {
|
||||
base.Awake();
|
||||
startEndModifier.Awake(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Path that is currently being calculated or was last calculated.
|
||||
/// You should rarely have to use this. Instead get the path when the path callback is called.
|
||||
///
|
||||
/// See: pathCallback
|
||||
/// </summary>
|
||||
public Path GetCurrentPath () {
|
||||
return path;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stop calculating the current path request.
|
||||
/// If this Seeker is currently calculating a path it will be canceled.
|
||||
/// The callback (usually to a method named OnPathComplete) will soon be called
|
||||
/// with a path that has the 'error' field set to true.
|
||||
///
|
||||
/// This does not stop the character from moving, it just aborts
|
||||
/// the path calculation.
|
||||
/// </summary>
|
||||
/// <param name="pool">If true then the path will be pooled when the pathfinding system is done with it.</param>
|
||||
public void CancelCurrentPathRequest (bool pool = true) {
|
||||
if (!IsDone()) {
|
||||
path.FailWithError("Canceled by script (Seeker.CancelCurrentPathRequest)");
|
||||
if (pool) {
|
||||
// Make sure the path has had its reference count incremented and decremented once.
|
||||
// If this is not done the system will think no pooling is used at all and will not pool the path.
|
||||
// The particular object that is used as the parameter (in this case 'path') doesn't matter at all
|
||||
// it just has to be *some* object.
|
||||
path.Claim(path);
|
||||
path.Release(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cleans up some variables.
|
||||
/// Releases any eventually claimed paths.
|
||||
/// Calls OnDestroy on the <see cref="startEndModifier"/>.
|
||||
///
|
||||
/// See: <see cref="ReleaseClaimedPath"/>
|
||||
/// See: <see cref="startEndModifier"/>
|
||||
/// </summary>
|
||||
public void OnDestroy () {
|
||||
ReleaseClaimedPath();
|
||||
startEndModifier.OnDestroy(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Releases the path used for gizmos (if any).
|
||||
/// The seeker keeps the latest path claimed so it can draw gizmos.
|
||||
/// In some cases this might not be desireable and you want it released.
|
||||
/// In that case, you can call this method to release it (not that path gizmos will then not be drawn).
|
||||
///
|
||||
/// If you didn't understand anything from the description above, you probably don't need to use this method.
|
||||
///
|
||||
/// See: pooling (view in online documentation for working links)
|
||||
/// </summary>
|
||||
void ReleaseClaimedPath () {
|
||||
if (prevPath != null) {
|
||||
prevPath.Release(this, true);
|
||||
prevPath = null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Called by modifiers to register themselves</summary>
|
||||
public void RegisterModifier (IPathModifier modifier) {
|
||||
modifiers.Add(modifier);
|
||||
|
||||
// Sort the modifiers based on their specified order
|
||||
modifiers.Sort((a, b) => a.Order.CompareTo(b.Order));
|
||||
}
|
||||
|
||||
/// <summary>Called by modifiers when they are disabled or destroyed</summary>
|
||||
public void DeregisterModifier (IPathModifier modifier) {
|
||||
modifiers.Remove(modifier);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Post Processes the path.
|
||||
/// This will run any modifiers attached to this GameObject on the path.
|
||||
/// This is identical to calling RunModifiers(ModifierPass.PostProcess, path)
|
||||
/// See: RunModifiers
|
||||
/// Since: Added in 3.2
|
||||
/// </summary>
|
||||
public void PostProcess (Path path) {
|
||||
RunModifiers(ModifierPass.PostProcess, path);
|
||||
}
|
||||
|
||||
/// <summary>Runs modifiers on a path</summary>
|
||||
public void RunModifiers (ModifierPass pass, Path path) {
|
||||
if (pass == ModifierPass.PreProcess) {
|
||||
if (preProcessPath != null) preProcessPath(path);
|
||||
|
||||
for (int i = 0; i < modifiers.Count; i++) modifiers[i].PreProcess(path);
|
||||
} else if (pass == ModifierPass.PostProcess) {
|
||||
Profiler.BeginSample("Running Path Modifiers");
|
||||
// Call delegates if they exist
|
||||
if (postProcessPath != null) postProcessPath(path);
|
||||
|
||||
// Loop through all modifiers and apply post processing
|
||||
for (int i = 0; i < modifiers.Count; i++) modifiers[i].Apply(path);
|
||||
Profiler.EndSample();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Is the current path done calculating.
|
||||
/// Returns true if the current <see cref="path"/> has been returned or if the <see cref="path"/> is null.
|
||||
///
|
||||
/// Note: Do not confuse this with Pathfinding.Path.IsDone. They usually return the same value, but not always
|
||||
/// since the path might be completely calculated, but it has not yet been processed by the Seeker.
|
||||
///
|
||||
/// Since: Added in 3.0.8
|
||||
/// Version: Behaviour changed in 3.2
|
||||
/// </summary>
|
||||
public bool IsDone () {
|
||||
return path == null || path.PipelineState >= PathState.Returned;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when a path has completed.
|
||||
/// This should have been implemented as optional parameter values, but that didn't seem to work very well with delegates (the values weren't the default ones)
|
||||
/// See: OnPathComplete(Path,bool,bool)
|
||||
/// </summary>
|
||||
void OnPathComplete (Path path) {
|
||||
OnPathComplete(path, true, true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when a path has completed.
|
||||
/// Will post process it and return it by calling <see cref="tmpPathCallback"/> and <see cref="pathCallback"/>
|
||||
/// </summary>
|
||||
void OnPathComplete (Path p, bool runModifiers, bool sendCallbacks) {
|
||||
if (p != null && p != path && sendCallbacks) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this == null || p == null || p != path)
|
||||
return;
|
||||
|
||||
if (!path.error && runModifiers) {
|
||||
// This will send the path for post processing to modifiers attached to this Seeker
|
||||
RunModifiers(ModifierPass.PostProcess, path);
|
||||
}
|
||||
|
||||
if (sendCallbacks) {
|
||||
p.Claim(this);
|
||||
|
||||
lastCompletedNodePath = p.path;
|
||||
lastCompletedVectorPath = p.vectorPath;
|
||||
|
||||
// This will send the path to the callback (if any) specified when calling StartPath
|
||||
if (tmpPathCallback != null) {
|
||||
tmpPathCallback(p);
|
||||
}
|
||||
|
||||
// This will send the path to any script which has registered to the callback
|
||||
if (pathCallback != null) {
|
||||
pathCallback(p);
|
||||
}
|
||||
|
||||
// Note: it is important that #prevPath is kept alive (i.e. not pooled)
|
||||
// if we are drawing gizmos.
|
||||
// It is also important that #path is kept alive since it can be returned
|
||||
// from the GetCurrentPath method.
|
||||
// Since #path will be copied to #prevPath it is sufficient that #prevPath
|
||||
// is kept alive until it is replaced.
|
||||
|
||||
// Recycle the previous path to reduce the load on the GC
|
||||
if (prevPath != null) {
|
||||
prevPath.Release(this, true);
|
||||
}
|
||||
|
||||
prevPath = p;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called for each path in a MultiTargetPath.
|
||||
/// Only post processes the path, does not return it.
|
||||
/// </summary>
|
||||
void OnPartialPathComplete (Path p) {
|
||||
OnPathComplete(p, true, false);
|
||||
}
|
||||
|
||||
/// <summary>Called once for a MultiTargetPath. Only returns the path, does not post process.</summary>
|
||||
void OnMultiPathComplete (Path p) {
|
||||
OnPathComplete(p, false, true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a new path instance.
|
||||
/// The path will be taken from the path pool if path recycling is turned on.
|
||||
/// This path can be sent to <see cref="StartPath(Path,OnPathDelegate,int)"/> with no change, but if no change is required <see cref="StartPath(Vector3,Vector3,OnPathDelegate)"/> does just that.
|
||||
/// <code>
|
||||
/// var seeker = GetComponent<Seeker>();
|
||||
/// Path p = seeker.GetNewPath (transform.position, transform.position+transform.forward*100);
|
||||
/// // Disable heuristics on just this path for example
|
||||
/// p.heuristic = Heuristic.None;
|
||||
/// seeker.StartPath (p, OnPathComplete);
|
||||
/// </code>
|
||||
/// Deprecated: Use ABPath.Construct(start, end, null) instead.
|
||||
/// </summary>
|
||||
[System.Obsolete("Use ABPath.Construct(start, end, null) instead")]
|
||||
public ABPath GetNewPath (Vector3 start, Vector3 end) {
|
||||
// Construct a path with start and end points
|
||||
return ABPath.Construct(start, end, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Call this function to start calculating a path.
|
||||
/// Since this method does not take a callback parameter, you should set the <see cref="pathCallback"/> field before calling this method.
|
||||
/// </summary>
|
||||
/// <param name="start">The start point of the path</param>
|
||||
/// <param name="end">The end point of the path</param>
|
||||
public Path StartPath (Vector3 start, Vector3 end) {
|
||||
return StartPath(start, end, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Call this function to start calculating a path.
|
||||
///
|
||||
/// The callback will be called when the path has been calculated (which may be several frames into the future).
|
||||
/// Callback will not be called if the path is canceled (e.g when a new path is requested before the previous one has completed)
|
||||
/// </summary>
|
||||
/// <param name="start">The start point of the path</param>
|
||||
/// <param name="end">The end point of the path</param>
|
||||
/// <param name="callback">The function to call when the path has been calculated</param>
|
||||
public Path StartPath (Vector3 start, Vector3 end, OnPathDelegate callback) {
|
||||
return StartPath(ABPath.Construct(start, end, null), callback);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Call this function to start calculating a path.
|
||||
///
|
||||
/// The callback will be called when the path has been calculated (which may be several frames into the future).
|
||||
/// Callback will not be called if the path is canceled (e.g when a new path is requested before the previous one has completed)
|
||||
/// </summary>
|
||||
/// <param name="start">The start point of the path</param>
|
||||
/// <param name="end">The end point of the path</param>
|
||||
/// <param name="callback">The function to call when the path has been calculated</param>
|
||||
/// <param name="graphMask">Mask used to specify which graphs should be searched for close nodes. See #Pathfinding.NNConstraint.graphMask. This will override #graphMask for this path request.</param>
|
||||
public Path StartPath (Vector3 start, Vector3 end, OnPathDelegate callback, GraphMask graphMask) {
|
||||
return StartPath(ABPath.Construct(start, end, null), callback, graphMask);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Call this function to start calculating a path.
|
||||
///
|
||||
/// The callback will be called when the path has been calculated (which may be several frames into the future).
|
||||
/// The callback will not be called if a new path request is started before this path request has been calculated.
|
||||
///
|
||||
/// Version: Since 3.8.3 this method works properly if a MultiTargetPath is used.
|
||||
/// It now behaves identically to the StartMultiTargetPath(MultiTargetPath) method.
|
||||
///
|
||||
/// Version: Since 4.1.x this method will no longer overwrite the graphMask on the path unless it is explicitly passed as a parameter (see other overloads of this method).
|
||||
/// </summary>
|
||||
/// <param name="p">The path to start calculating</param>
|
||||
/// <param name="callback">The function to call when the path has been calculated</param>
|
||||
public Path StartPath (Path p, OnPathDelegate callback = null) {
|
||||
// Set the graph mask only if the user has not changed it from the default value.
|
||||
// This is not perfect as the user may have wanted it to be precisely -1
|
||||
// however it is the best detection that I can do.
|
||||
// The non-default check is primarily for compatibility reasons to avoid breaking peoples existing code.
|
||||
// The StartPath overloads with an explicit graphMask field should be used instead to set the graphMask.
|
||||
if (p.nnConstraint.graphMask == -1) p.nnConstraint.graphMask = graphMask;
|
||||
StartPathInternal(p, callback);
|
||||
return p;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Call this function to start calculating a path.
|
||||
///
|
||||
/// The callback will be called when the path has been calculated (which may be several frames into the future).
|
||||
/// The callback will not be called if a new path request is started before this path request has been calculated.
|
||||
///
|
||||
/// Version: Since 3.8.3 this method works properly if a MultiTargetPath is used.
|
||||
/// It now behaves identically to the StartMultiTargetPath(MultiTargetPath) method.
|
||||
/// </summary>
|
||||
/// <param name="p">The path to start calculating</param>
|
||||
/// <param name="callback">The function to call when the path has been calculated</param>
|
||||
/// <param name="graphMask">Mask used to specify which graphs should be searched for close nodes. See #Pathfinding.GraphMask. This will override #graphMask for this path request.</param>
|
||||
public Path StartPath (Path p, OnPathDelegate callback, GraphMask graphMask) {
|
||||
p.nnConstraint.graphMask = graphMask;
|
||||
StartPathInternal(p, callback);
|
||||
return p;
|
||||
}
|
||||
|
||||
/// <summary>Internal method to start a path and mark it as the currently active path</summary>
|
||||
void StartPathInternal (Path p, OnPathDelegate callback) {
|
||||
var mtp = p as MultiTargetPath;
|
||||
if (mtp != null) {
|
||||
// TODO: Allocation, cache
|
||||
var callbacks = new OnPathDelegate[mtp.targetPoints.Length];
|
||||
|
||||
for (int i = 0; i < callbacks.Length; i++) {
|
||||
callbacks[i] = onPartialPathDelegate;
|
||||
}
|
||||
|
||||
mtp.callbacks = callbacks;
|
||||
p.callback += OnMultiPathComplete;
|
||||
} else {
|
||||
p.callback += onPathDelegate;
|
||||
}
|
||||
|
||||
p.enabledTags = traversableTags;
|
||||
p.tagPenalties = tagPenalties;
|
||||
|
||||
// Cancel a previously requested path is it has not been processed yet and also make sure that it has not been recycled and used somewhere else
|
||||
if (path != null && path.PipelineState <= PathState.Processing && path.CompleteState != PathCompleteState.Error && lastPathID == path.pathID) {
|
||||
path.FailWithError("Canceled path because a new one was requested.\n"+
|
||||
"This happens when a new path is requested from the seeker when one was already being calculated.\n" +
|
||||
"For example if a unit got a new order, you might request a new path directly instead of waiting for the now" +
|
||||
" invalid path to be calculated. Which is probably what you want.\n" +
|
||||
"If you are getting this a lot, you might want to consider how you are scheduling path requests.");
|
||||
// No callback will be sent for the canceled path
|
||||
}
|
||||
|
||||
// Set p as the active path
|
||||
path = p;
|
||||
tmpPathCallback = callback;
|
||||
|
||||
// Save the path id so we can make sure that if we cancel a path (see above) it should not have been recycled yet.
|
||||
lastPathID = path.pathID;
|
||||
|
||||
// Pre process the path
|
||||
RunModifiers(ModifierPass.PreProcess, path);
|
||||
|
||||
// Send the request to the pathfinder
|
||||
AstarPath.StartPath(path);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Starts a Multi Target Path from one start point to multiple end points.
|
||||
/// A Multi Target Path will search for all the end points in one search and will return all paths if pathsForAll is true, or only the shortest one if pathsForAll is false.
|
||||
///
|
||||
/// callback and <see cref="pathCallback"/> will be called when the path has completed. Callback will not be called if the path is canceled (e.g when a new path is requested before the previous one has completed)
|
||||
///
|
||||
/// See: Pathfinding.MultiTargetPath
|
||||
/// See: MultiTargetPathExample.cs (view in online documentation for working links) "Example of how to use multi-target-paths"
|
||||
/// </summary>
|
||||
/// <param name="start">The start point of the path</param>
|
||||
/// <param name="endPoints">The end points of the path</param>
|
||||
/// <param name="pathsForAll">Indicates whether or not a path to all end points should be searched for or only to the closest one</param>
|
||||
/// <param name="callback">The function to call when the path has been calculated</param>
|
||||
/// <param name="graphMask">Mask used to specify which graphs should be searched for close nodes. See Pathfinding.NNConstraint.graphMask.</param>
|
||||
public MultiTargetPath StartMultiTargetPath (Vector3 start, Vector3[] endPoints, bool pathsForAll, OnPathDelegate callback = null, int graphMask = -1) {
|
||||
MultiTargetPath p = MultiTargetPath.Construct(start, endPoints, null, null);
|
||||
|
||||
p.pathsForAll = pathsForAll;
|
||||
StartPath(p, callback, graphMask);
|
||||
return p;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Starts a Multi Target Path from multiple start points to a single target point.
|
||||
/// A Multi Target Path will search from all start points to the target point in one search and will return all paths if pathsForAll is true, or only the shortest one if pathsForAll is false.
|
||||
///
|
||||
/// callback and <see cref="pathCallback"/> will be called when the path has completed. Callback will not be called if the path is canceled (e.g when a new path is requested before the previous one has completed)
|
||||
///
|
||||
/// See: Pathfinding.MultiTargetPath
|
||||
/// See: MultiTargetPathExample.cs (view in online documentation for working links) "Example of how to use multi-target-paths"
|
||||
/// </summary>
|
||||
/// <param name="startPoints">The start points of the path</param>
|
||||
/// <param name="end">The end point of the path</param>
|
||||
/// <param name="pathsForAll">Indicates whether or not a path from all start points should be searched for or only to the closest one</param>
|
||||
/// <param name="callback">The function to call when the path has been calculated</param>
|
||||
/// <param name="graphMask">Mask used to specify which graphs should be searched for close nodes. See Pathfinding.NNConstraint.graphMask.</param>
|
||||
public MultiTargetPath StartMultiTargetPath (Vector3[] startPoints, Vector3 end, bool pathsForAll, OnPathDelegate callback = null, int graphMask = -1) {
|
||||
MultiTargetPath p = MultiTargetPath.Construct(startPoints, end, null, null);
|
||||
|
||||
p.pathsForAll = pathsForAll;
|
||||
StartPath(p, callback, graphMask);
|
||||
return p;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Starts a Multi Target Path.
|
||||
/// Takes a MultiTargetPath and wires everything up for it to send callbacks to the seeker for post-processing.
|
||||
///
|
||||
/// callback and <see cref="pathCallback"/> will be called when the path has completed. Callback will not be called if the path is canceled (e.g when a new path is requested before the previous one has completed)
|
||||
///
|
||||
/// See: Pathfinding.MultiTargetPath
|
||||
/// See: MultiTargetPathExample.cs (view in online documentation for working links) "Example of how to use multi-target-paths"
|
||||
///
|
||||
/// Version: Since 3.8.3 calling this method behaves identically to calling StartPath with a MultiTargetPath.
|
||||
/// Version: Since 3.8.3 this method also sets enabledTags and tagPenalties on the path object.
|
||||
///
|
||||
/// Deprecated: You can use StartPath instead of this method now. It will behave identically.
|
||||
/// </summary>
|
||||
/// <param name="p">The path to start calculating</param>
|
||||
/// <param name="callback">The function to call when the path has been calculated</param>
|
||||
/// <param name="graphMask">Mask used to specify which graphs should be searched for close nodes. See Pathfinding.NNConstraint.graphMask.</param>
|
||||
[System.Obsolete("You can use StartPath instead of this method now. It will behave identically.")]
|
||||
public MultiTargetPath StartMultiTargetPath (MultiTargetPath p, OnPathDelegate callback = null, int graphMask = -1) {
|
||||
StartPath(p, callback, graphMask);
|
||||
return p;
|
||||
}
|
||||
|
||||
/// <summary>Draws gizmos for the Seeker</summary>
|
||||
public void OnDrawGizmos () {
|
||||
if (lastCompletedNodePath == null || !drawGizmos) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (detailedGizmos) {
|
||||
Gizmos.color = new Color(0.7F, 0.5F, 0.1F, 0.5F);
|
||||
|
||||
if (lastCompletedNodePath != null) {
|
||||
for (int i = 0; i < lastCompletedNodePath.Count-1; i++) {
|
||||
Gizmos.DrawLine((Vector3)lastCompletedNodePath[i].position, (Vector3)lastCompletedNodePath[i+1].position);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Gizmos.color = new Color(0, 1F, 0, 1F);
|
||||
|
||||
if (lastCompletedVectorPath != null) {
|
||||
for (int i = 0; i < lastCompletedVectorPath.Count-1; i++) {
|
||||
Gizmos.DrawLine(lastCompletedVectorPath[i], lastCompletedVectorPath[i+1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override int OnUpgradeSerializedData (int version, bool unityThread) {
|
||||
if (graphMaskCompatibility != -1) {
|
||||
Debug.Log("Loaded " + graphMaskCompatibility + " " + graphMask.value);
|
||||
graphMask = graphMaskCompatibility;
|
||||
graphMaskCompatibility = -1;
|
||||
}
|
||||
return base.OnUpgradeSerializedData(version, unityThread);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 373b52eb9bf8c40f785bb6947a1aee66
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
@ -0,0 +1,25 @@
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Pathfinding.Examples {
|
||||
/// <summary>Helper script in the example scene 'Turn Based'</summary>
|
||||
[HelpURL("http://arongranberg.com/astar/documentation/stable/class_pathfinding_1_1_examples_1_1_turn_based_a_i.php")]
|
||||
public class TurnBasedAI : VersionedMonoBehaviour {
|
||||
public int movementPoints = 2;
|
||||
public BlockManager blockManager;
|
||||
public SingleNodeBlocker blocker;
|
||||
public GraphNode targetNode;
|
||||
public BlockManager.TraversalProvider traversalProvider;
|
||||
|
||||
void Start () {
|
||||
blocker.BlockAtCurrentPosition();
|
||||
}
|
||||
|
||||
protected override void Awake () {
|
||||
base.Awake();
|
||||
// Set the traversal provider to block all nodes that are blocked by a SingleNodeBlocker
|
||||
// except the SingleNodeBlocker owned by this AI (we don't want to be blocked by ourself)
|
||||
traversalProvider = new BlockManager.TraversalProvider(blockManager, BlockManager.BlockMode.AllExceptSelector, new List<SingleNodeBlocker>() { blocker });
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8f95b80c439d6408b9afac9d013922e4
|
||||
timeCreated: 1453035991
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
748
BlueWater/Assets/AstarPathfindingProject/Core/AstarData.cs
Normal file
748
BlueWater/Assets/AstarPathfindingProject/Core/AstarData.cs
Normal file
@ -0,0 +1,748 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Pathfinding.WindowsStore;
|
||||
using Pathfinding.Serialization;
|
||||
#if UNITY_WINRT && !UNITY_EDITOR
|
||||
//using MarkerMetro.Unity.WinLegacy.IO;
|
||||
//using MarkerMetro.Unity.WinLegacy.Reflection;
|
||||
#endif
|
||||
|
||||
namespace Pathfinding {
|
||||
[System.Serializable]
|
||||
/// <summary>
|
||||
/// Stores the navigation graphs for the A* Pathfinding System.
|
||||
///
|
||||
/// An instance of this class is assigned to AstarPath.data, from it you can access all graphs loaded through the <see cref="graphs"/> variable.
|
||||
/// This class also handles a lot of the high level serialization.
|
||||
/// </summary>
|
||||
public class AstarData {
|
||||
/// <summary>Shortcut to AstarPath.active</summary>
|
||||
public static AstarPath active {
|
||||
get {
|
||||
return AstarPath.active;
|
||||
}
|
||||
}
|
||||
|
||||
#region Fields
|
||||
/// <summary>
|
||||
/// Shortcut to the first NavMeshGraph.
|
||||
/// Updated at scanning time
|
||||
/// </summary>
|
||||
public NavMeshGraph navmesh { get; private set; }
|
||||
|
||||
#if !ASTAR_NO_GRID_GRAPH
|
||||
/// <summary>
|
||||
/// Shortcut to the first GridGraph.
|
||||
/// Updated at scanning time
|
||||
/// </summary>
|
||||
public GridGraph gridGraph { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Shortcut to the first LayerGridGraph.
|
||||
/// Updated at scanning time.
|
||||
/// </summary>
|
||||
public LayerGridGraph layerGridGraph { get; private set; }
|
||||
#endif
|
||||
|
||||
#if !ASTAR_NO_POINT_GRAPH
|
||||
/// <summary>
|
||||
/// Shortcut to the first PointGraph.
|
||||
/// Updated at scanning time
|
||||
/// </summary>
|
||||
public PointGraph pointGraph { get; private set; }
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Shortcut to the first RecastGraph.
|
||||
/// Updated at scanning time.
|
||||
/// </summary>
|
||||
public RecastGraph recastGraph { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// All supported graph types.
|
||||
/// Populated through reflection search
|
||||
/// </summary>
|
||||
public System.Type[] graphTypes { get; private set; }
|
||||
|
||||
#if ASTAR_FAST_NO_EXCEPTIONS || UNITY_WINRT || UNITY_WEBGL
|
||||
/// <summary>
|
||||
/// Graph types to use when building with Fast But No Exceptions for iPhone.
|
||||
/// If you add any custom graph types, you need to add them to this hard-coded list.
|
||||
/// </summary>
|
||||
public static readonly System.Type[] DefaultGraphTypes = new System.Type[] {
|
||||
#if !ASTAR_NO_GRID_GRAPH
|
||||
typeof(GridGraph),
|
||||
typeof(LayerGridGraph),
|
||||
#endif
|
||||
#if !ASTAR_NO_POINT_GRAPH
|
||||
typeof(PointGraph),
|
||||
#endif
|
||||
typeof(NavMeshGraph),
|
||||
typeof(RecastGraph),
|
||||
};
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// All graphs this instance holds.
|
||||
/// This will be filled only after deserialization has completed.
|
||||
/// May contain null entries if graph have been removed.
|
||||
/// </summary>
|
||||
[System.NonSerialized]
|
||||
public NavGraph[] graphs = new NavGraph[0];
|
||||
|
||||
//Serialization Settings
|
||||
|
||||
/// <summary>
|
||||
/// Serialized data for all graphs and settings.
|
||||
/// Stored as a base64 encoded string because otherwise Unity's Undo system would sometimes corrupt the byte data (because it only stores deltas).
|
||||
///
|
||||
/// This can be accessed as a byte array from the <see cref="data"/> property.
|
||||
///
|
||||
/// Since: 3.6.1
|
||||
/// </summary>
|
||||
[SerializeField]
|
||||
string dataString;
|
||||
|
||||
/// <summary>
|
||||
/// Data from versions from before 3.6.1.
|
||||
/// Used for handling upgrades
|
||||
/// Since: 3.6.1
|
||||
/// </summary>
|
||||
[SerializeField]
|
||||
[UnityEngine.Serialization.FormerlySerializedAs("data")]
|
||||
private byte[] upgradeData;
|
||||
|
||||
/// <summary>Serialized data for all graphs and settings</summary>
|
||||
private byte[] data {
|
||||
get {
|
||||
// Handle upgrading from earlier versions than 3.6.1
|
||||
if (upgradeData != null && upgradeData.Length > 0) {
|
||||
data = upgradeData;
|
||||
upgradeData = null;
|
||||
}
|
||||
return dataString != null? System.Convert.FromBase64String(dataString) : null;
|
||||
}
|
||||
set {
|
||||
dataString = value != null? System.Convert.ToBase64String(value) : null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serialized data for cached startup.
|
||||
/// If set, on start the graphs will be deserialized from this file.
|
||||
/// </summary>
|
||||
public TextAsset file_cachedStartup;
|
||||
|
||||
/// <summary>
|
||||
/// Serialized data for cached startup.
|
||||
///
|
||||
/// Deprecated: Deprecated since 3.6, AstarData.file_cachedStartup is now used instead
|
||||
/// </summary>
|
||||
public byte[] data_cachedStartup;
|
||||
|
||||
/// <summary>
|
||||
/// Should graph-data be cached.
|
||||
/// Caching the startup means saving the whole graphs - not only the settings - to a file (<see cref="file_cachedStartup)"/> which can
|
||||
/// be loaded when the game starts. This is usually much faster than scanning the graphs when the game starts. This is configured from the editor under the "Save & Load" tab.
|
||||
///
|
||||
/// See: save-load-graphs (view in online documentation for working links)
|
||||
/// </summary>
|
||||
[SerializeField]
|
||||
public bool cacheStartup;
|
||||
|
||||
//End Serialization Settings
|
||||
|
||||
List<bool> graphStructureLocked = new List<bool>();
|
||||
|
||||
#endregion
|
||||
|
||||
public byte[] GetData () {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void SetData (byte[] data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
/// <summary>Loads the graphs from memory, will load cached graphs if any exists</summary>
|
||||
public void Awake () {
|
||||
graphs = new NavGraph[0];
|
||||
|
||||
if (cacheStartup && file_cachedStartup != null) {
|
||||
LoadFromCache();
|
||||
} else {
|
||||
DeserializeGraphs();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Prevent the graph structure from changing during the time this lock is held.
|
||||
/// This prevents graphs from being added or removed and also prevents graphs from being serialized or deserialized.
|
||||
/// This is used when e.g an async scan is happening to ensure that for example a graph that is being scanned is not destroyed.
|
||||
///
|
||||
/// Each call to this method *must* be paired with exactly one call to <see cref="UnlockGraphStructure"/>.
|
||||
/// The calls may be nested.
|
||||
/// </summary>
|
||||
internal void LockGraphStructure (bool allowAddingGraphs = false) {
|
||||
graphStructureLocked.Add(allowAddingGraphs);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Allows the graph structure to change again.
|
||||
/// See: <see cref="LockGraphStructure"/>
|
||||
/// </summary>
|
||||
internal void UnlockGraphStructure () {
|
||||
if (graphStructureLocked.Count == 0) throw new System.InvalidOperationException();
|
||||
graphStructureLocked.RemoveAt(graphStructureLocked.Count - 1);
|
||||
}
|
||||
|
||||
PathProcessor.GraphUpdateLock AssertSafe (bool onlyAddingGraph = false) {
|
||||
if (graphStructureLocked.Count > 0) {
|
||||
bool allowAdding = true;
|
||||
for (int i = 0; i < graphStructureLocked.Count; i++) allowAdding &= graphStructureLocked[i];
|
||||
if (!(onlyAddingGraph && allowAdding)) throw new System.InvalidOperationException("Graphs cannot be added, removed or serialized while the graph structure is locked. This is the case when a graph is currently being scanned and when executing graph updates and work items.\nHowever as a special case, graphs can be added inside work items.");
|
||||
}
|
||||
|
||||
// Pause the pathfinding threads
|
||||
var graphLock = active.PausePathfinding();
|
||||
if (!active.IsInsideWorkItem) {
|
||||
// Make sure all graph updates and other callbacks are done
|
||||
// Only do this if this code is not being called from a work item itself as that would cause a recursive wait that could never complete.
|
||||
// There are some valid cases when this can happen. For example it may be necessary to add a new graph inside a work item.
|
||||
active.FlushWorkItems();
|
||||
|
||||
// Paths that are already calculated and waiting to be returned to the Seeker component need to be
|
||||
// processed immediately as their results usually depend on graphs that currently exist. If this was
|
||||
// not done then after destroying a graph one could get a path result with destroyed nodes in it.
|
||||
active.pathReturnQueue.ReturnPaths(false);
|
||||
}
|
||||
return graphLock;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calls the callback with every node in all graphs.
|
||||
/// This is the easiest way to iterate through every existing node.
|
||||
///
|
||||
/// <code>
|
||||
/// AstarPath.active.data.GetNodes(node => {
|
||||
/// Debug.Log("I found a node at position " + (Vector3)node.position);
|
||||
/// });
|
||||
/// </code>
|
||||
///
|
||||
/// See: <see cref="Pathfinding.NavGraph.GetNodes"/> for getting the nodes of a single graph instead of all.
|
||||
/// See: graph-updates (view in online documentation for working links)
|
||||
/// </summary>
|
||||
public void GetNodes (System.Action<GraphNode> callback) {
|
||||
for (int i = 0; i < graphs.Length; i++) {
|
||||
if (graphs[i] != null) graphs[i].GetNodes(callback);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates shortcuts to the first graph of different types.
|
||||
/// Hard coding references to some graph types is not really a good thing imo. I want to keep it dynamic and flexible.
|
||||
/// But these references ease the use of the system, so I decided to keep them.
|
||||
/// </summary>
|
||||
public void UpdateShortcuts () {
|
||||
navmesh = (NavMeshGraph)FindGraphOfType(typeof(NavMeshGraph));
|
||||
|
||||
#if !ASTAR_NO_GRID_GRAPH
|
||||
gridGraph = (GridGraph)FindGraphOfType(typeof(GridGraph));
|
||||
layerGridGraph = (LayerGridGraph)FindGraphOfType(typeof(LayerGridGraph));
|
||||
#endif
|
||||
|
||||
#if !ASTAR_NO_POINT_GRAPH
|
||||
pointGraph = (PointGraph)FindGraphOfType(typeof(PointGraph));
|
||||
#endif
|
||||
|
||||
recastGraph = (RecastGraph)FindGraphOfType(typeof(RecastGraph));
|
||||
}
|
||||
|
||||
/// <summary>Load from data from <see cref="file_cachedStartup"/></summary>
|
||||
public void LoadFromCache () {
|
||||
var graphLock = AssertSafe();
|
||||
|
||||
if (file_cachedStartup != null) {
|
||||
var bytes = file_cachedStartup.bytes;
|
||||
DeserializeGraphs(bytes);
|
||||
|
||||
GraphModifier.TriggerEvent(GraphModifier.EventType.PostCacheLoad);
|
||||
} else {
|
||||
Debug.LogError("Can't load from cache since the cache is empty");
|
||||
}
|
||||
graphLock.Release();
|
||||
}
|
||||
|
||||
#region Serialization
|
||||
|
||||
/// <summary>
|
||||
/// Serializes all graphs settings to a byte array.
|
||||
/// See: DeserializeGraphs(byte[])
|
||||
/// </summary>
|
||||
public byte[] SerializeGraphs () {
|
||||
return SerializeGraphs(SerializeSettings.Settings);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes all graphs settings and optionally node data to a byte array.
|
||||
/// See: DeserializeGraphs(byte[])
|
||||
/// See: Pathfinding.Serialization.SerializeSettings
|
||||
/// </summary>
|
||||
public byte[] SerializeGraphs (SerializeSettings settings) {
|
||||
uint checksum;
|
||||
|
||||
return SerializeGraphs(settings, out checksum);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Main serializer function.
|
||||
/// Serializes all graphs to a byte array
|
||||
/// A similar function exists in the AstarPathEditor.cs script to save additional info
|
||||
/// </summary>
|
||||
public byte[] SerializeGraphs (SerializeSettings settings, out uint checksum) {
|
||||
var graphLock = AssertSafe();
|
||||
var sr = new AstarSerializer(this, settings, active.gameObject);
|
||||
|
||||
sr.OpenSerialize();
|
||||
sr.SerializeGraphs(graphs);
|
||||
sr.SerializeExtraInfo();
|
||||
byte[] bytes = sr.CloseSerialize();
|
||||
checksum = sr.GetChecksum();
|
||||
#if ASTARDEBUG
|
||||
Debug.Log("Got a whole bunch of data, "+bytes.Length+" bytes");
|
||||
#endif
|
||||
graphLock.Release();
|
||||
return bytes;
|
||||
}
|
||||
|
||||
/// <summary>Deserializes graphs from <see cref="data"/></summary>
|
||||
public void DeserializeGraphs () {
|
||||
if (data != null) {
|
||||
DeserializeGraphs(data);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Destroys all graphs and sets graphs to null</summary>
|
||||
void ClearGraphs () {
|
||||
if (graphs == null) return;
|
||||
for (int i = 0; i < graphs.Length; i++) {
|
||||
if (graphs[i] != null) {
|
||||
((IGraphInternals)graphs[i]).OnDestroy();
|
||||
graphs[i].active = null;
|
||||
}
|
||||
}
|
||||
graphs = new NavGraph[0];
|
||||
UpdateShortcuts();
|
||||
}
|
||||
|
||||
public void OnDestroy () {
|
||||
ClearGraphs();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes graphs from the specified byte array.
|
||||
/// An error will be logged if deserialization fails.
|
||||
/// </summary>
|
||||
public void DeserializeGraphs (byte[] bytes) {
|
||||
var graphLock = AssertSafe();
|
||||
|
||||
ClearGraphs();
|
||||
DeserializeGraphsAdditive(bytes);
|
||||
graphLock.Release();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes graphs from the specified byte array additively.
|
||||
/// An error will be logged if deserialization fails.
|
||||
/// This function will add loaded graphs to the current ones.
|
||||
/// </summary>
|
||||
public void DeserializeGraphsAdditive (byte[] bytes) {
|
||||
var graphLock = AssertSafe();
|
||||
|
||||
try {
|
||||
if (bytes != null) {
|
||||
var sr = new AstarSerializer(this, active.gameObject);
|
||||
|
||||
if (sr.OpenDeserialize(bytes)) {
|
||||
DeserializeGraphsPartAdditive(sr);
|
||||
sr.CloseDeserialize();
|
||||
} else {
|
||||
Debug.Log("Invalid data file (cannot read zip).\nThe data is either corrupt or it was saved using a 3.0.x or earlier version of the system");
|
||||
}
|
||||
} else {
|
||||
throw new System.ArgumentNullException("bytes");
|
||||
}
|
||||
active.VerifyIntegrity();
|
||||
} catch (System.Exception e) {
|
||||
Debug.LogError("Caught exception while deserializing data.\n"+e);
|
||||
graphs = new NavGraph[0];
|
||||
}
|
||||
|
||||
UpdateShortcuts();
|
||||
graphLock.Release();
|
||||
}
|
||||
|
||||
/// <summary>Helper function for deserializing graphs</summary>
|
||||
void DeserializeGraphsPartAdditive (AstarSerializer sr) {
|
||||
if (graphs == null) graphs = new NavGraph[0];
|
||||
|
||||
var gr = new List<NavGraph>(graphs);
|
||||
|
||||
// Set an offset so that the deserializer will load
|
||||
// the graphs with the correct graph indexes
|
||||
sr.SetGraphIndexOffset(gr.Count);
|
||||
|
||||
if (graphTypes == null) FindGraphTypes();
|
||||
gr.AddRange(sr.DeserializeGraphs(graphTypes));
|
||||
graphs = gr.ToArray();
|
||||
|
||||
sr.DeserializeEditorSettingsCompatibility();
|
||||
sr.DeserializeExtraInfo();
|
||||
|
||||
//Assign correct graph indices.
|
||||
for (int i = 0; i < graphs.Length; i++) {
|
||||
if (graphs[i] == null) continue;
|
||||
graphs[i].GetNodes(node => node.GraphIndex = (uint)i);
|
||||
}
|
||||
|
||||
for (int i = 0; i < graphs.Length; i++) {
|
||||
for (int j = i+1; j < graphs.Length; j++) {
|
||||
if (graphs[i] != null && graphs[j] != null && graphs[i].guid == graphs[j].guid) {
|
||||
Debug.LogWarning("Guid Conflict when importing graphs additively. Imported graph will get a new Guid.\nThis message is (relatively) harmless.");
|
||||
graphs[i].guid = Pathfinding.Util.Guid.NewGuid();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sr.PostDeserialization();
|
||||
active.hierarchicalGraph.RecalculateIfNecessary();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Find all graph types supported in this build.
|
||||
/// Using reflection, the assembly is searched for types which inherit from NavGraph.
|
||||
/// </summary>
|
||||
public void FindGraphTypes () {
|
||||
#if !ASTAR_FAST_NO_EXCEPTIONS && !UNITY_WINRT && !UNITY_WEBGL
|
||||
var graphList = new List<System.Type>();
|
||||
foreach (var assembly in System.AppDomain.CurrentDomain.GetAssemblies()) {
|
||||
System.Type[] types = null;
|
||||
try {
|
||||
types = assembly.GetTypes();
|
||||
} catch {
|
||||
// Ignore type load exceptions and things like that.
|
||||
// We might not be able to read all assemblies for some reason, but hopefully the relevant types exist in the assemblies that we can read
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach (var type in types) {
|
||||
#if NETFX_CORE && !UNITY_EDITOR
|
||||
System.Type baseType = type.GetTypeInfo().BaseType;
|
||||
#else
|
||||
var baseType = type.BaseType;
|
||||
#endif
|
||||
while (baseType != null) {
|
||||
if (System.Type.Equals(baseType, typeof(NavGraph))) {
|
||||
graphList.Add(type);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
#if NETFX_CORE && !UNITY_EDITOR
|
||||
baseType = baseType.GetTypeInfo().BaseType;
|
||||
#else
|
||||
baseType = baseType.BaseType;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
graphTypes = graphList.ToArray();
|
||||
|
||||
#if ASTARDEBUG
|
||||
Debug.Log("Found "+graphTypes.Length+" graph types");
|
||||
#endif
|
||||
#else
|
||||
graphTypes = DefaultGraphTypes;
|
||||
#endif
|
||||
}
|
||||
|
||||
#region GraphCreation
|
||||
/// <summary>
|
||||
/// Returns: A System.Type which matches the specified type string. If no mathing graph type was found, null is returned
|
||||
///
|
||||
/// Deprecated:
|
||||
/// </summary>
|
||||
[System.Obsolete("If really necessary. Use System.Type.GetType instead.")]
|
||||
public System.Type GetGraphType (string type) {
|
||||
for (int i = 0; i < graphTypes.Length; i++) {
|
||||
if (graphTypes[i].Name == type) {
|
||||
return graphTypes[i];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of a graph of type type. If no matching graph type was found, an error is logged and null is returned
|
||||
/// Returns: The created graph
|
||||
/// See: <see cref="CreateGraph(System.Type)"/>
|
||||
///
|
||||
/// Deprecated:
|
||||
/// </summary>
|
||||
[System.Obsolete("Use CreateGraph(System.Type) instead")]
|
||||
public NavGraph CreateGraph (string type) {
|
||||
Debug.Log("Creating Graph of type '"+type+"'");
|
||||
|
||||
for (int i = 0; i < graphTypes.Length; i++) {
|
||||
if (graphTypes[i].Name == type) {
|
||||
return CreateGraph(graphTypes[i]);
|
||||
}
|
||||
}
|
||||
Debug.LogError("Graph type ("+type+") wasn't found");
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new graph instance of type type
|
||||
/// See: <see cref="CreateGraph(string)"/>
|
||||
/// </summary>
|
||||
internal NavGraph CreateGraph (System.Type type) {
|
||||
var graph = System.Activator.CreateInstance(type) as NavGraph;
|
||||
|
||||
graph.active = active;
|
||||
return graph;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a graph of type type to the <see cref="graphs"/> array
|
||||
///
|
||||
/// Deprecated:
|
||||
/// </summary>
|
||||
[System.Obsolete("Use AddGraph(System.Type) instead")]
|
||||
public NavGraph AddGraph (string type) {
|
||||
NavGraph graph = null;
|
||||
|
||||
for (int i = 0; i < graphTypes.Length; i++) {
|
||||
if (graphTypes[i].Name == type) {
|
||||
graph = CreateGraph(graphTypes[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if (graph == null) {
|
||||
Debug.LogError("No NavGraph of type '"+type+"' could be found");
|
||||
return null;
|
||||
}
|
||||
|
||||
AddGraph(graph);
|
||||
|
||||
return graph;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a graph of type type to the <see cref="graphs"/> array.
|
||||
/// See: runtime-graphs (view in online documentation for working links)
|
||||
/// </summary>
|
||||
public NavGraph AddGraph (System.Type type) {
|
||||
NavGraph graph = null;
|
||||
|
||||
for (int i = 0; i < graphTypes.Length; i++) {
|
||||
if (System.Type.Equals(graphTypes[i], type)) {
|
||||
graph = CreateGraph(graphTypes[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if (graph == null) {
|
||||
Debug.LogError("No NavGraph of type '"+type+"' could be found, "+graphTypes.Length+" graph types are avaliable");
|
||||
return null;
|
||||
}
|
||||
|
||||
AddGraph(graph);
|
||||
|
||||
return graph;
|
||||
}
|
||||
|
||||
/// <summary>Adds the specified graph to the <see cref="graphs"/> array</summary>
|
||||
void AddGraph (NavGraph graph) {
|
||||
// Make sure to not interfere with pathfinding
|
||||
var graphLock = AssertSafe(true);
|
||||
|
||||
// Try to fill in an empty position
|
||||
bool foundEmpty = false;
|
||||
|
||||
for (int i = 0; i < graphs.Length; i++) {
|
||||
if (graphs[i] == null) {
|
||||
graphs[i] = graph;
|
||||
graph.graphIndex = (uint)i;
|
||||
foundEmpty = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!foundEmpty) {
|
||||
if (graphs != null && graphs.Length >= GraphNode.MaxGraphIndex) {
|
||||
throw new System.Exception("Graph Count Limit Reached. You cannot have more than " + GraphNode.MaxGraphIndex + " graphs.");
|
||||
}
|
||||
|
||||
// Add a new entry to the list
|
||||
var graphList = new List<NavGraph>(graphs ?? new NavGraph[0]);
|
||||
graphList.Add(graph);
|
||||
graphs = graphList.ToArray();
|
||||
graph.graphIndex = (uint)(graphs.Length-1);
|
||||
}
|
||||
|
||||
UpdateShortcuts();
|
||||
graph.active = active;
|
||||
graphLock.Release();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes the specified graph from the <see cref="graphs"/> array and Destroys it in a safe manner.
|
||||
/// To avoid changing graph indices for the other graphs, the graph is simply nulled in the array instead
|
||||
/// of actually removing it from the array.
|
||||
/// The empty position will be reused if a new graph is added.
|
||||
///
|
||||
/// Returns: True if the graph was sucessfully removed (i.e it did exist in the <see cref="graphs"/> array). False otherwise.
|
||||
///
|
||||
/// Version: Changed in 3.2.5 to call SafeOnDestroy before removing
|
||||
/// and nulling it in the array instead of removing the element completely in the <see cref="graphs"/> array.
|
||||
/// </summary>
|
||||
public bool RemoveGraph (NavGraph graph) {
|
||||
// Make sure the pathfinding threads are stopped
|
||||
// If we don't wait until pathfinding that is potentially running on
|
||||
// this graph right now we could end up with NullReferenceExceptions
|
||||
var graphLock = AssertSafe();
|
||||
|
||||
((IGraphInternals)graph).OnDestroy();
|
||||
graph.active = null;
|
||||
|
||||
int i = System.Array.IndexOf(graphs, graph);
|
||||
if (i != -1) graphs[i] = null;
|
||||
|
||||
UpdateShortcuts();
|
||||
graphLock.Release();
|
||||
return i != -1;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GraphUtility
|
||||
|
||||
/// <summary>
|
||||
/// Returns the graph which contains the specified node.
|
||||
/// The graph must be in the <see cref="graphs"/> array.
|
||||
///
|
||||
/// Returns: Returns the graph which contains the node. Null if the graph wasn't found
|
||||
/// </summary>
|
||||
public static NavGraph GetGraph (GraphNode node) {
|
||||
if (node == null) return null;
|
||||
|
||||
AstarPath script = AstarPath.active;
|
||||
if (script == null) return null;
|
||||
|
||||
AstarData data = script.data;
|
||||
if (data == null || data.graphs == null) return null;
|
||||
|
||||
uint graphIndex = node.GraphIndex;
|
||||
|
||||
if (graphIndex >= data.graphs.Length) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return data.graphs[(int)graphIndex];
|
||||
}
|
||||
|
||||
/// <summary>Returns the first graph which satisfies the predicate. Returns null if no graph was found.</summary>
|
||||
public NavGraph FindGraph (System.Func<NavGraph, bool> predicate) {
|
||||
if (graphs != null) {
|
||||
for (int i = 0; i < graphs.Length; i++) {
|
||||
if (graphs[i] != null && predicate(graphs[i])) {
|
||||
return graphs[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>Returns the first graph of type type found in the <see cref="graphs"/> array. Returns null if no graph was found.</summary>
|
||||
public NavGraph FindGraphOfType (System.Type type) {
|
||||
return FindGraph(graph => System.Type.Equals(graph.GetType(), type));
|
||||
}
|
||||
|
||||
/// <summary>Returns the first graph which inherits from the type type. Returns null if no graph was found.</summary>
|
||||
public NavGraph FindGraphWhichInheritsFrom (System.Type type) {
|
||||
return FindGraph(graph => WindowsStoreCompatibility.GetTypeInfo(type).IsAssignableFrom(WindowsStoreCompatibility.GetTypeInfo(graph.GetType())));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Loop through this function to get all graphs of type 'type'
|
||||
/// <code>
|
||||
/// foreach (GridGraph graph in AstarPath.data.FindGraphsOfType (typeof(GridGraph))) {
|
||||
/// //Do something with the graph
|
||||
/// }
|
||||
/// </code>
|
||||
/// See: AstarPath.RegisterSafeNodeUpdate
|
||||
/// </summary>
|
||||
public IEnumerable FindGraphsOfType (System.Type type) {
|
||||
if (graphs == null) yield break;
|
||||
for (int i = 0; i < graphs.Length; i++) {
|
||||
if (graphs[i] != null && System.Type.Equals(graphs[i].GetType(), type)) {
|
||||
yield return graphs[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// All graphs which implements the UpdateableGraph interface
|
||||
/// <code> foreach (IUpdatableGraph graph in AstarPath.data.GetUpdateableGraphs ()) {
|
||||
/// //Do something with the graph
|
||||
/// } </code>
|
||||
/// See: AstarPath.AddWorkItem
|
||||
/// See: Pathfinding.IUpdatableGraph
|
||||
/// </summary>
|
||||
public IEnumerable GetUpdateableGraphs () {
|
||||
if (graphs == null) yield break;
|
||||
for (int i = 0; i < graphs.Length; i++) {
|
||||
if (graphs[i] is IUpdatableGraph) {
|
||||
yield return graphs[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// All graphs which implements the UpdateableGraph interface
|
||||
/// <code> foreach (IRaycastableGraph graph in AstarPath.data.GetRaycastableGraphs ()) {
|
||||
/// //Do something with the graph
|
||||
/// } </code>
|
||||
/// See: Pathfinding.IRaycastableGraph
|
||||
/// Deprecated: Deprecated because it is not used by the package internally and the use cases are few. Iterate through the <see cref="graphs"/> array instead.
|
||||
/// </summary>
|
||||
[System.Obsolete("Obsolete because it is not used by the package internally and the use cases are few. Iterate through the graphs array instead.")]
|
||||
public IEnumerable GetRaycastableGraphs () {
|
||||
if (graphs == null) yield break;
|
||||
for (int i = 0; i < graphs.Length; i++) {
|
||||
if (graphs[i] is IRaycastableGraph) {
|
||||
yield return graphs[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Gets the index of the NavGraph in the <see cref="graphs"/> array</summary>
|
||||
public int GetGraphIndex (NavGraph graph) {
|
||||
if (graph == null) throw new System.ArgumentNullException("graph");
|
||||
|
||||
var index = -1;
|
||||
if (graphs != null) {
|
||||
index = System.Array.IndexOf(graphs, graph);
|
||||
if (index == -1) Debug.LogError("Graph doesn't exist");
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 38d211caa07cb44ef886481aa1cf755c
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
1540
BlueWater/Assets/AstarPathfindingProject/Core/AstarMath.cs
Normal file
1540
BlueWater/Assets/AstarPathfindingProject/Core/AstarMath.cs
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 960fd9020b1f74f939fee737c3c0f491
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
2160
BlueWater/Assets/AstarPathfindingProject/Core/AstarPath.cs
Normal file
2160
BlueWater/Assets/AstarPathfindingProject/Core/AstarPath.cs
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,16 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 78396926cbbfc4ac3b48fc5fc34a87d1
|
||||
labels:
|
||||
- Pathfinder
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences:
|
||||
- gizmoSurfaceMaterial: {fileID: 2100000, guid: 5ce51318bbfb1466188b929a68a6bd3a,
|
||||
type: 2}
|
||||
- gizmoLineMaterial: {fileID: 2100000, guid: 91035448860ba4e708919485c73f7edc, type: 2}
|
||||
executionOrder: -10000
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,398 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Pathfinding {
|
||||
[AddComponentMenu("Pathfinding/GraphUpdateScene")]
|
||||
/// <summary>
|
||||
/// Helper class for easily updating graphs.
|
||||
///
|
||||
/// The GraphUpdateScene component is really easy to use. Create a new empty GameObject and add the component to it, it can be found in Components-->Pathfinding-->GraphUpdateScene.
|
||||
/// When you have added the component, you should see something like the image below.
|
||||
/// [Open online documentation to see images]
|
||||
/// The region which the component will affect is defined by creating a polygon in the scene.
|
||||
/// If you make sure you have the Position tool enabled (top-left corner of the Unity window) you can shift+click in the scene view to add more points to the polygon.
|
||||
/// You can remove points using shift+alt+click.
|
||||
/// By clicking on the points you can bring up a positioning tool. You can also open the "points" array in the inspector to set each point's coordinates manually.
|
||||
/// [Open online documentation to see images]
|
||||
/// In the inspector there are a number of variables. The first one is named "Convex", it sets if the convex hull of the points should be calculated or if the polygon should be used as-is.
|
||||
/// Using the convex hull is faster when applying the changes to the graph, but with a non-convex polygon you can specify more complicated areas.
|
||||
/// The next two variables, called "Apply On Start" and "Apply On Scan" determine when to apply the changes. If the object is in the scene from the beginning, both can be left on, it doesn't
|
||||
/// matter since the graph is also scanned at start. However if you instantiate it later in the game, you can make it apply it's setting directly, or wait until the next scan (if any).
|
||||
/// If the graph is rescanned, all GraphUpdateScene components which have the Apply On Scan variable toggled will apply their settings again to the graph since rescanning clears all previous changes.
|
||||
/// You can also make it apply it's changes using scripting.
|
||||
/// <code> GetComponent<GraphUpdateScene>().Apply (); </code>
|
||||
/// The above code will make it apply its changes to the graph (assuming a GraphUpdateScene component is attached to the same GameObject).
|
||||
///
|
||||
/// Next there is "Modify Walkability" and "Set Walkability" (which appears when "Modify Walkability" is toggled).
|
||||
/// If Modify Walkability is set, then all nodes inside the area will either be set to walkable or unwalkable depending on the value of the "Set Walkability" variable.
|
||||
///
|
||||
/// Penalty can also be applied to the nodes. A higher penalty (aka weight) makes the nodes harder to traverse so it will try to avoid those areas.
|
||||
///
|
||||
/// The tagging variables can be read more about on this page: tags (view in online documentation for working links) "Working with tags".
|
||||
///
|
||||
/// Note: The Y (up) axis of the transform that this component is attached to should be in the same direction as the up direction of the graph.
|
||||
/// So if you for example have a grid in the XY plane then the transform should have the rotation (-90,0,0).
|
||||
/// </summary>
|
||||
[HelpURL("http://arongranberg.com/astar/documentation/stable/class_pathfinding_1_1_graph_update_scene.php")]
|
||||
public class GraphUpdateScene : GraphModifier {
|
||||
/// <summary>Points which define the region to update</summary>
|
||||
public Vector3[] points;
|
||||
|
||||
/// <summary>Private cached convex hull of the <see cref="points"/></summary>
|
||||
private Vector3[] convexPoints;
|
||||
|
||||
/// <summary>
|
||||
/// Use the convex hull of the points instead of the original polygon.
|
||||
///
|
||||
/// See: https://en.wikipedia.org/wiki/Convex_hull
|
||||
/// </summary>
|
||||
public bool convex = true;
|
||||
|
||||
/// <summary>
|
||||
/// Minumum height of the bounds of the resulting Graph Update Object.
|
||||
/// Useful when all points are laid out on a plane but you still need a bounds with a height greater than zero since a
|
||||
/// zero height graph update object would usually result in no nodes being updated.
|
||||
/// </summary>
|
||||
public float minBoundsHeight = 1;
|
||||
|
||||
/// <summary>
|
||||
/// Penalty to add to nodes.
|
||||
/// Usually you need quite large values, at least 1000-10000. A higher penalty means that agents will try to avoid those nodes more.
|
||||
///
|
||||
/// Be careful when setting negative values since if a node gets a negative penalty it will underflow and instead get
|
||||
/// really large. In most cases a warning will be logged if that happens.
|
||||
///
|
||||
/// See: tags (view in online documentation for working links) for another way of applying penalties.
|
||||
/// </summary>
|
||||
public int penaltyDelta;
|
||||
|
||||
/// <summary>If true, then all affected nodes will be made walkable or unwalkable according to <see cref="setWalkability"/></summary>
|
||||
public bool modifyWalkability;
|
||||
|
||||
/// <summary>Nodes will be made walkable or unwalkable according to this value if <see cref="modifyWalkability"/> is true</summary>
|
||||
public bool setWalkability;
|
||||
|
||||
/// <summary>Apply this graph update object on start</summary>
|
||||
public bool applyOnStart = true;
|
||||
|
||||
/// <summary>Apply this graph update object whenever a graph is rescanned</summary>
|
||||
public bool applyOnScan = true;
|
||||
|
||||
/// <summary>
|
||||
/// Update node's walkability and connectivity using physics functions.
|
||||
/// For grid graphs, this will update the node's position and walkability exactly like when doing a scan of the graph.
|
||||
/// If enabled for grid graphs, <see cref="modifyWalkability"/> will be ignored.
|
||||
///
|
||||
/// For Point Graphs, this will recalculate all connections which passes through the bounds of the resulting Graph Update Object
|
||||
/// using raycasts (if enabled).
|
||||
/// </summary>
|
||||
public bool updatePhysics;
|
||||
|
||||
/// <summary>\copydoc Pathfinding::GraphUpdateObject::resetPenaltyOnPhysics</summary>
|
||||
public bool resetPenaltyOnPhysics = true;
|
||||
|
||||
/// <summary>\copydoc Pathfinding::GraphUpdateObject::updateErosion</summary>
|
||||
public bool updateErosion = true;
|
||||
|
||||
/// <summary>
|
||||
/// Should the tags of the nodes be modified.
|
||||
/// If enabled, set all nodes' tags to <see cref="setTag"/>
|
||||
/// </summary>
|
||||
public bool modifyTag;
|
||||
|
||||
/// <summary>If <see cref="modifyTag"/> is enabled, set all nodes' tags to this value</summary>
|
||||
public int setTag;
|
||||
|
||||
/// <summary>Emulates behavior from before version 4.0</summary>
|
||||
[HideInInspector]
|
||||
public bool legacyMode = false;
|
||||
|
||||
/// <summary>
|
||||
/// Private cached inversion of <see cref="setTag"/>.
|
||||
/// Used for InvertSettings()
|
||||
/// </summary>
|
||||
private int setTagInvert;
|
||||
|
||||
/// <summary>
|
||||
/// Has apply been called yet.
|
||||
/// Used to prevent applying twice when both applyOnScan and applyOnStart are enabled
|
||||
/// </summary>
|
||||
private bool firstApplied;
|
||||
|
||||
[SerializeField]
|
||||
private int serializedVersion = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Use world space for coordinates.
|
||||
/// If true, the shape will not follow when moving around the transform.
|
||||
///
|
||||
/// See: <see cref="ToggleUseWorldSpace"/>
|
||||
/// </summary>
|
||||
[SerializeField]
|
||||
[UnityEngine.Serialization.FormerlySerializedAs("useWorldSpace")]
|
||||
private bool legacyUseWorldSpace;
|
||||
|
||||
/// <summary>Do some stuff at start</summary>
|
||||
public void Start () {
|
||||
if (!Application.isPlaying) return;
|
||||
|
||||
// If firstApplied is true, that means the graph was scanned during Awake.
|
||||
// So we shouldn't apply it again because then we would end up applying it two times
|
||||
if (!firstApplied && applyOnStart) {
|
||||
Apply();
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnPostScan () {
|
||||
if (applyOnScan) Apply();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Inverts all invertable settings for this GUS.
|
||||
/// Namely: penalty delta, walkability, tags.
|
||||
///
|
||||
/// Penalty delta will be changed to negative penalty delta.
|
||||
/// <see cref="setWalkability"/> will be inverted.
|
||||
/// <see cref="setTag"/> will be stored in a private variable, and the new value will be 0. When calling this function again, the saved
|
||||
/// value will be the new value.
|
||||
///
|
||||
/// Calling this function an even number of times without changing any settings in between will be identical to no change in settings.
|
||||
/// </summary>
|
||||
public virtual void InvertSettings () {
|
||||
setWalkability = !setWalkability;
|
||||
penaltyDelta = -penaltyDelta;
|
||||
if (setTagInvert == 0) {
|
||||
setTagInvert = setTag;
|
||||
setTag = 0;
|
||||
} else {
|
||||
setTag = setTagInvert;
|
||||
setTagInvert = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recalculate convex hull.
|
||||
/// Will not do anything if <see cref="convex"/> is disabled.
|
||||
/// </summary>
|
||||
public void RecalcConvex () {
|
||||
convexPoints = convex ? Polygon.ConvexHullXZ(points) : null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Switches between using world space and using local space.
|
||||
/// Deprecated: World space can no longer be used as it does not work well with rotated graphs. Use transform.InverseTransformPoint to transform points to local space.
|
||||
/// </summary>
|
||||
[System.ObsoleteAttribute("World space can no longer be used as it does not work well with rotated graphs. Use transform.InverseTransformPoint to transform points to local space.", true)]
|
||||
void ToggleUseWorldSpace () {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Lock all points to a specific Y value.
|
||||
/// Deprecated: The Y coordinate is no longer important. Use the position of the object instead.
|
||||
/// </summary>
|
||||
[System.ObsoleteAttribute("The Y coordinate is no longer important. Use the position of the object instead", true)]
|
||||
public void LockToY () {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calculates the bounds for this component.
|
||||
/// This is a relatively expensive operation, it needs to go through all points and
|
||||
/// run matrix multiplications.
|
||||
/// </summary>
|
||||
public Bounds GetBounds () {
|
||||
if (points == null || points.Length == 0) {
|
||||
Bounds bounds;
|
||||
var coll = GetComponent<Collider>();
|
||||
var coll2D = GetComponent<Collider2D>();
|
||||
var rend = GetComponent<Renderer>();
|
||||
|
||||
if (coll != null) bounds = coll.bounds;
|
||||
else if (coll2D != null) {
|
||||
bounds = coll2D.bounds;
|
||||
bounds.size = new Vector3(bounds.size.x, bounds.size.y, Mathf.Max(bounds.size.z, 1f));
|
||||
} else if (rend != null) {
|
||||
bounds = rend.bounds;
|
||||
} else {
|
||||
return new Bounds(Vector3.zero, Vector3.zero);
|
||||
}
|
||||
|
||||
if (legacyMode && bounds.size.y < minBoundsHeight) bounds.size = new Vector3(bounds.size.x, minBoundsHeight, bounds.size.z);
|
||||
return bounds;
|
||||
} else {
|
||||
return GraphUpdateShape.GetBounds(convex ? convexPoints : points, legacyMode && legacyUseWorldSpace ? Matrix4x4.identity : transform.localToWorldMatrix, minBoundsHeight);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates graphs with a created GUO.
|
||||
/// Creates a Pathfinding.GraphUpdateObject with a Pathfinding.GraphUpdateShape
|
||||
/// representing the polygon of this object and update all graphs using AstarPath.UpdateGraphs.
|
||||
/// This will not update graphs immediately. See AstarPath.UpdateGraph for more info.
|
||||
/// </summary>
|
||||
public void Apply () {
|
||||
if (AstarPath.active == null) {
|
||||
Debug.LogError("There is no AstarPath object in the scene", this);
|
||||
return;
|
||||
}
|
||||
|
||||
GraphUpdateObject guo;
|
||||
|
||||
if (points == null || points.Length == 0) {
|
||||
var polygonCollider = GetComponent<PolygonCollider2D>();
|
||||
if (polygonCollider != null) {
|
||||
var points2D = polygonCollider.points;
|
||||
Vector3[] pts = new Vector3[points2D.Length];
|
||||
for (int i = 0; i < pts.Length; i++) {
|
||||
var p = points2D[i] + polygonCollider.offset;
|
||||
pts[i] = new Vector3(p.x, 0, p.y);
|
||||
}
|
||||
|
||||
var mat = transform.localToWorldMatrix * Matrix4x4.TRS(Vector3.zero, Quaternion.Euler(-90, 0, 0), Vector3.one);
|
||||
var shape = new GraphUpdateShape(pts, convex, mat, minBoundsHeight);
|
||||
guo = new GraphUpdateObject(GetBounds());
|
||||
guo.shape = shape;
|
||||
} else {
|
||||
var bounds = GetBounds();
|
||||
if (bounds.center == Vector3.zero && bounds.size == Vector3.zero) {
|
||||
Debug.LogError("Cannot apply GraphUpdateScene, no points defined and no renderer or collider attached", this);
|
||||
return;
|
||||
}
|
||||
|
||||
guo = new GraphUpdateObject(bounds);
|
||||
}
|
||||
} else {
|
||||
GraphUpdateShape shape;
|
||||
if (legacyMode && !legacyUseWorldSpace) {
|
||||
// Used for compatibility with older versions
|
||||
var worldPoints = new Vector3[points.Length];
|
||||
for (int i = 0; i < points.Length; i++) worldPoints[i] = transform.TransformPoint(points[i]);
|
||||
shape = new GraphUpdateShape(worldPoints, convex, Matrix4x4.identity, minBoundsHeight);
|
||||
} else {
|
||||
shape = new GraphUpdateShape(points, convex, legacyMode && legacyUseWorldSpace ? Matrix4x4.identity : transform.localToWorldMatrix, minBoundsHeight);
|
||||
}
|
||||
var bounds = shape.GetBounds();
|
||||
guo = new GraphUpdateObject(bounds);
|
||||
guo.shape = shape;
|
||||
}
|
||||
|
||||
firstApplied = true;
|
||||
|
||||
guo.modifyWalkability = modifyWalkability;
|
||||
guo.setWalkability = setWalkability;
|
||||
guo.addPenalty = penaltyDelta;
|
||||
guo.updatePhysics = updatePhysics;
|
||||
guo.updateErosion = updateErosion;
|
||||
guo.resetPenaltyOnPhysics = resetPenaltyOnPhysics;
|
||||
|
||||
guo.modifyTag = modifyTag;
|
||||
guo.setTag = setTag;
|
||||
|
||||
AstarPath.active.UpdateGraphs(guo);
|
||||
}
|
||||
|
||||
/// <summary>Draws some gizmos</summary>
|
||||
void OnDrawGizmos () {
|
||||
OnDrawGizmos(false);
|
||||
}
|
||||
|
||||
/// <summary>Draws some gizmos</summary>
|
||||
void OnDrawGizmosSelected () {
|
||||
OnDrawGizmos(true);
|
||||
}
|
||||
|
||||
/// <summary>Draws some gizmos</summary>
|
||||
void OnDrawGizmos (bool selected) {
|
||||
Color c = selected ? new Color(227/255f, 61/255f, 22/255f, 1.0f) : new Color(227/255f, 61/255f, 22/255f, 0.9f);
|
||||
|
||||
if (selected) {
|
||||
Gizmos.color = Color.Lerp(c, new Color(1, 1, 1, 0.2f), 0.9f);
|
||||
|
||||
Bounds b = GetBounds();
|
||||
Gizmos.DrawCube(b.center, b.size);
|
||||
Gizmos.DrawWireCube(b.center, b.size);
|
||||
}
|
||||
|
||||
if (points == null) return;
|
||||
|
||||
if (convex) c.a *= 0.5f;
|
||||
|
||||
Gizmos.color = c;
|
||||
|
||||
Matrix4x4 matrix = legacyMode && legacyUseWorldSpace ? Matrix4x4.identity : transform.localToWorldMatrix;
|
||||
|
||||
if (convex) {
|
||||
c.r -= 0.1f;
|
||||
c.g -= 0.2f;
|
||||
c.b -= 0.1f;
|
||||
|
||||
Gizmos.color = c;
|
||||
}
|
||||
|
||||
if (selected || !convex) {
|
||||
for (int i = 0; i < points.Length; i++) {
|
||||
Gizmos.DrawLine(matrix.MultiplyPoint3x4(points[i]), matrix.MultiplyPoint3x4(points[(i+1)%points.Length]));
|
||||
}
|
||||
}
|
||||
|
||||
if (convex) {
|
||||
if (convexPoints == null) RecalcConvex();
|
||||
|
||||
Gizmos.color = selected ? new Color(227/255f, 61/255f, 22/255f, 1.0f) : new Color(227/255f, 61/255f, 22/255f, 0.9f);
|
||||
|
||||
for (int i = 0; i < convexPoints.Length; i++) {
|
||||
Gizmos.DrawLine(matrix.MultiplyPoint3x4(convexPoints[i]), matrix.MultiplyPoint3x4(convexPoints[(i+1)%convexPoints.Length]));
|
||||
}
|
||||
}
|
||||
|
||||
// Draw the full 3D shape
|
||||
var pts = convex ? convexPoints : points;
|
||||
if (selected && pts != null && pts.Length > 0) {
|
||||
Gizmos.color = new Color(1, 1, 1, 0.2f);
|
||||
float miny = pts[0].y, maxy = pts[0].y;
|
||||
for (int i = 0; i < pts.Length; i++) {
|
||||
miny = Mathf.Min(miny, pts[i].y);
|
||||
maxy = Mathf.Max(maxy, pts[i].y);
|
||||
}
|
||||
var extraHeight = Mathf.Max(minBoundsHeight - (maxy - miny), 0) * 0.5f;
|
||||
miny -= extraHeight;
|
||||
maxy += extraHeight;
|
||||
|
||||
for (int i = 0; i < pts.Length; i++) {
|
||||
var next = (i+1) % pts.Length;
|
||||
var p1 = matrix.MultiplyPoint3x4(pts[i] + Vector3.up*(miny - pts[i].y));
|
||||
var p2 = matrix.MultiplyPoint3x4(pts[i] + Vector3.up*(maxy - pts[i].y));
|
||||
var p1n = matrix.MultiplyPoint3x4(pts[next] + Vector3.up*(miny - pts[next].y));
|
||||
var p2n = matrix.MultiplyPoint3x4(pts[next] + Vector3.up*(maxy - pts[next].y));
|
||||
Gizmos.DrawLine(p1, p2);
|
||||
Gizmos.DrawLine(p1, p1n);
|
||||
Gizmos.DrawLine(p2, p2n);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Disables legacy mode if it is enabled.
|
||||
/// Legacy mode is automatically enabled for components when upgrading from an earlier version than 3.8.6.
|
||||
/// </summary>
|
||||
public void DisableLegacyMode () {
|
||||
if (legacyMode) {
|
||||
legacyMode = false;
|
||||
if (legacyUseWorldSpace) {
|
||||
legacyUseWorldSpace = false;
|
||||
for (int i = 0; i < points.Length; i++) {
|
||||
points[i] = transform.InverseTransformPoint(points[i]);
|
||||
}
|
||||
RecalcConvex();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Awake () {
|
||||
if (serializedVersion == 0) {
|
||||
// Use the old behavior if some points are already set
|
||||
if (points != null && points.Length > 0) legacyMode = true;
|
||||
serializedVersion = 1;
|
||||
}
|
||||
base.Awake();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: efee954c69f0d421086729bb8df1137f
|
||||
timeCreated: 1490044676
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: -221
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,143 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Pathfinding {
|
||||
/// <summary>
|
||||
/// Defines a shape for a Pathfinding.GraphUpdateObject.
|
||||
/// The shape consists of a number of points which it can either calculate the convex hull of or use as a polygon directly.
|
||||
///
|
||||
/// A shape is essentially a 2D shape however it can be rotated arbitrarily.
|
||||
/// When a matrix and a list of points is specified in the constructor the matrix decides what direction
|
||||
/// is the 'up' direction. When checking if a point is contained in the shape, the point will be projected down
|
||||
/// on a plane where the 'up' direction is the normal and then it will check if the shape contains the point.
|
||||
///
|
||||
/// See: Pathfinding.GraphUpdateObject.shape
|
||||
/// </summary>
|
||||
public class GraphUpdateShape {
|
||||
Vector3[] _points;
|
||||
Vector3[] _convexPoints;
|
||||
bool _convex;
|
||||
Vector3 right = Vector3.right;
|
||||
Vector3 forward = Vector3.forward;
|
||||
Vector3 up = Vector3.up;
|
||||
Vector3 origin;
|
||||
public float minimumHeight;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the points of the polygon in the shape.
|
||||
/// These points should be specified in clockwise order.
|
||||
/// Will automatically calculate the convex hull if <see cref="convex"/> is set to true
|
||||
/// </summary>
|
||||
public Vector3[] points {
|
||||
get {
|
||||
return _points;
|
||||
}
|
||||
set {
|
||||
_points = value;
|
||||
if (convex) CalculateConvexHull();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets if the convex hull of the points should be calculated.
|
||||
/// Convex hulls are faster but non-convex hulls can be used to specify more complicated shapes.
|
||||
/// </summary>
|
||||
public bool convex {
|
||||
get {
|
||||
return _convex;
|
||||
}
|
||||
set {
|
||||
if (_convex != value && value) {
|
||||
CalculateConvexHull();
|
||||
}
|
||||
_convex = value;
|
||||
}
|
||||
}
|
||||
|
||||
public GraphUpdateShape () {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Construct a shape.
|
||||
/// See: <see cref="convex"/>
|
||||
/// </summary>
|
||||
/// <param name="points">Contour of the shape in local space with respect to the matrix (i.e the shape should be in the XZ plane, the Y coordinate will only affect the bounds)</param>
|
||||
/// <param name="convex">If true, the convex hull of the points will be calculated.</param>
|
||||
/// <param name="matrix">local to world space matrix for the points. The matrix determines the up direction of the shape.</param>
|
||||
/// <param name="minimumHeight">If the points would be in the XZ plane only, the shape would not have a height and then it might not
|
||||
/// include any points inside it (as testing for inclusion is done in 3D space when updating graphs). This ensures
|
||||
/// that the shape has at least the minimum height (in the up direction that the matrix specifies).</param>
|
||||
public GraphUpdateShape (Vector3[] points, bool convex, Matrix4x4 matrix, float minimumHeight) {
|
||||
this.convex = convex;
|
||||
this.points = points;
|
||||
origin = matrix.MultiplyPoint3x4(Vector3.zero);
|
||||
right = matrix.MultiplyPoint3x4(Vector3.right) - origin;
|
||||
up = matrix.MultiplyPoint3x4(Vector3.up) - origin;
|
||||
forward = matrix.MultiplyPoint3x4(Vector3.forward) - origin;
|
||||
this.minimumHeight = minimumHeight;
|
||||
}
|
||||
|
||||
void CalculateConvexHull () {
|
||||
_convexPoints = points != null? Polygon.ConvexHullXZ(points) : null;
|
||||
}
|
||||
|
||||
/// <summary>World space bounding box of this shape</summary>
|
||||
public Bounds GetBounds () {
|
||||
return GetBounds(convex ? _convexPoints : points, right, up, forward, origin, minimumHeight);
|
||||
}
|
||||
|
||||
public static Bounds GetBounds (Vector3[] points, Matrix4x4 matrix, float minimumHeight) {
|
||||
var origin = matrix.MultiplyPoint3x4(Vector3.zero);
|
||||
var right = matrix.MultiplyPoint3x4(Vector3.right) - origin;
|
||||
var up = matrix.MultiplyPoint3x4(Vector3.up) - origin;
|
||||
var forward = matrix.MultiplyPoint3x4(Vector3.forward) - origin;
|
||||
|
||||
return GetBounds(points, right, up, forward, origin, minimumHeight);
|
||||
}
|
||||
|
||||
static Bounds GetBounds (Vector3[] points, Vector3 right, Vector3 up, Vector3 forward, Vector3 origin, float minimumHeight) {
|
||||
if (points == null || points.Length == 0) return new Bounds();
|
||||
float miny = points[0].y, maxy = points[0].y;
|
||||
for (int i = 0; i < points.Length; i++) {
|
||||
miny = Mathf.Min(miny, points[i].y);
|
||||
maxy = Mathf.Max(maxy, points[i].y);
|
||||
}
|
||||
var extraHeight = Mathf.Max(minimumHeight - (maxy - miny), 0) * 0.5f;
|
||||
miny -= extraHeight;
|
||||
maxy += extraHeight;
|
||||
|
||||
Vector3 min = right * points[0].x + up * points[0].y + forward * points[0].z;
|
||||
Vector3 max = min;
|
||||
for (int i = 0; i < points.Length; i++) {
|
||||
var p = right * points[i].x + forward * points[i].z;
|
||||
var p1 = p + up * miny;
|
||||
var p2 = p + up * maxy;
|
||||
min = Vector3.Min(min, p1);
|
||||
min = Vector3.Min(min, p2);
|
||||
max = Vector3.Max(max, p1);
|
||||
max = Vector3.Max(max, p2);
|
||||
}
|
||||
return new Bounds((min+max)*0.5F + origin, max-min);
|
||||
}
|
||||
|
||||
public bool Contains (GraphNode node) {
|
||||
return Contains((Vector3)node.position);
|
||||
}
|
||||
|
||||
public bool Contains (Vector3 point) {
|
||||
// Transform to local space (shape in the XZ plane)
|
||||
point -= origin;
|
||||
var localSpacePoint = new Vector3(Vector3.Dot(point, right)/right.sqrMagnitude, 0, Vector3.Dot(point, forward)/forward.sqrMagnitude);
|
||||
|
||||
if (convex) {
|
||||
if (_convexPoints == null) return false;
|
||||
|
||||
for (int i = 0, j = _convexPoints.Length-1; i < _convexPoints.Length; j = i, i++) {
|
||||
if (VectorMath.RightOrColinearXZ(_convexPoints[i], _convexPoints[j], localSpacePoint)) return false;
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return _points != null && Polygon.ContainsPointXZ(_points, localSpacePoint);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1c31d3b0be14344e98aa458dc66c3a94
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
2
BlueWater/Assets/AstarPathfindingProject/Core/Misc.meta
Normal file
2
BlueWater/Assets/AstarPathfindingProject/Core/Misc.meta
Normal file
@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dfc976d61106d46b6a18ace94ffaea8d
|
@ -0,0 +1,122 @@
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Pathfinding {
|
||||
[HelpURL("http://arongranberg.com/astar/documentation/stable/class_pathfinding_1_1_animation_link.php")]
|
||||
public class AnimationLink : NodeLink2 {
|
||||
public string clip;
|
||||
public float animSpeed = 1;
|
||||
public bool reverseAnim = true;
|
||||
|
||||
public GameObject referenceMesh;
|
||||
public LinkClip[] sequence;
|
||||
public string boneRoot = "bn_COG_Root";
|
||||
|
||||
[System.Serializable]
|
||||
public class LinkClip {
|
||||
public AnimationClip clip;
|
||||
public Vector3 velocity;
|
||||
public int loopCount = 1;
|
||||
|
||||
public string name {
|
||||
get {
|
||||
return clip != null ? clip.name : "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static Transform SearchRec (Transform tr, string name) {
|
||||
int childCount = tr.childCount;
|
||||
|
||||
for (int i = 0; i < childCount; i++) {
|
||||
Transform ch = tr.GetChild(i);
|
||||
if (ch.name == name) return ch;
|
||||
else {
|
||||
Transform rec = SearchRec(ch, name);
|
||||
if (rec != null) return rec;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void CalculateOffsets (List<Vector3> trace, out Vector3 endPosition) {
|
||||
//Vector3 opos = transform.position;
|
||||
endPosition = transform.position;
|
||||
if (referenceMesh == null) return;
|
||||
|
||||
GameObject ob = GameObject.Instantiate(referenceMesh, transform.position, transform.rotation) as GameObject;
|
||||
ob.hideFlags = HideFlags.HideAndDontSave;
|
||||
|
||||
Transform root = SearchRec(ob.transform, boneRoot);
|
||||
if (root == null) throw new System.Exception("Could not find root transform");
|
||||
|
||||
Animation anim = ob.GetComponent<Animation>();
|
||||
if (anim == null) anim = ob.AddComponent<Animation>();
|
||||
|
||||
for (int i = 0; i < sequence.Length; i++) {
|
||||
anim.AddClip(sequence[i].clip, sequence[i].clip.name);
|
||||
}
|
||||
|
||||
Vector3 prevOffset = Vector3.zero;
|
||||
Vector3 position = transform.position;
|
||||
Vector3 firstOffset = Vector3.zero;
|
||||
|
||||
for (int i = 0; i < sequence.Length; i++) {
|
||||
LinkClip c = sequence[i];
|
||||
if (c == null) {
|
||||
endPosition = position;
|
||||
return;
|
||||
}
|
||||
|
||||
anim[c.clip.name].enabled = true;
|
||||
anim[c.clip.name].weight = 1;
|
||||
|
||||
for (int repeat = 0; repeat < c.loopCount; repeat++) {
|
||||
anim[c.clip.name].normalizedTime = 0;
|
||||
anim.Sample();
|
||||
Vector3 soffset = root.position - transform.position;
|
||||
|
||||
if (i > 0) {
|
||||
position += prevOffset - soffset;
|
||||
} else {
|
||||
firstOffset = soffset;
|
||||
}
|
||||
|
||||
for (int t = 0; t <= 20; t++) {
|
||||
float tf = t/20.0f;
|
||||
anim[c.clip.name].normalizedTime = tf;
|
||||
anim.Sample();
|
||||
Vector3 tmp = position + (root.position-transform.position) + c.velocity*tf*c.clip.length;
|
||||
trace.Add(tmp);
|
||||
}
|
||||
position = position + c.velocity*1*c.clip.length;
|
||||
|
||||
anim[c.clip.name].normalizedTime = 1;
|
||||
anim.Sample();
|
||||
Vector3 eoffset = root.position - transform.position;
|
||||
prevOffset = eoffset;
|
||||
}
|
||||
|
||||
anim[c.clip.name].enabled = false;
|
||||
anim[c.clip.name].weight = 0;
|
||||
}
|
||||
|
||||
position += prevOffset - firstOffset;
|
||||
|
||||
GameObject.DestroyImmediate(ob);
|
||||
|
||||
endPosition = position;
|
||||
}
|
||||
|
||||
public override void OnDrawGizmosSelected () {
|
||||
base.OnDrawGizmosSelected();
|
||||
List<Vector3> buffer = Pathfinding.Util.ListPool<Vector3>.Claim();
|
||||
Vector3 endPosition = Vector3.zero;
|
||||
CalculateOffsets(buffer, out endPosition);
|
||||
Gizmos.color = Color.blue;
|
||||
for (int i = 0; i < buffer.Count-1; i++) {
|
||||
Gizmos.DrawLine(buffer[i], buffer[i+1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d2e8b1fd6fa484fc29f8a26fb5e8662b
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
200
BlueWater/Assets/AstarPathfindingProject/Core/Misc/ArrayPool.cs
Normal file
200
BlueWater/Assets/AstarPathfindingProject/Core/Misc/ArrayPool.cs
Normal file
@ -0,0 +1,200 @@
|
||||
#if !UNITY_EDITOR
|
||||
// Extra optimizations when not running in the editor, but less error checking
|
||||
#define ASTAR_OPTIMIZE_POOLING
|
||||
#endif
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Pathfinding.Util {
|
||||
/// <summary>
|
||||
/// Lightweight Array Pool.
|
||||
/// Handy class for pooling arrays of type T.
|
||||
///
|
||||
/// Usage:
|
||||
/// - Claim a new array using <code> SomeClass[] foo = ArrayPool<SomeClass>.Claim (capacity); </code>
|
||||
/// - Use it and do stuff with it
|
||||
/// - Release it with <code> ArrayPool<SomeClass>.Release (foo); </code>
|
||||
///
|
||||
/// Warning: Arrays returned from the Claim method may contain arbitrary data.
|
||||
/// You cannot rely on it being zeroed out.
|
||||
///
|
||||
/// After you have released a array, you should never use it again, if you do use it
|
||||
/// your code may modify it at the same time as some other code is using it which
|
||||
/// will likely lead to bad results.
|
||||
///
|
||||
/// Since: Version 3.8.6
|
||||
/// See: Pathfinding.Util.ListPool
|
||||
/// </summary>
|
||||
public static class ArrayPool<T> {
|
||||
#if !ASTAR_NO_POOLING
|
||||
/// <summary>
|
||||
/// Maximum length of an array pooled using ClaimWithExactLength.
|
||||
/// Arrays with lengths longer than this will silently not be pooled.
|
||||
/// </summary>
|
||||
const int MaximumExactArrayLength = 256;
|
||||
|
||||
/// <summary>
|
||||
/// Internal pool.
|
||||
/// The arrays in each bucket have lengths of 2^i
|
||||
/// </summary>
|
||||
static readonly Stack<T[]>[] pool = new Stack<T[]>[31];
|
||||
static readonly Stack<T[]>[] exactPool = new Stack<T[]>[MaximumExactArrayLength+1];
|
||||
#if !ASTAR_OPTIMIZE_POOLING
|
||||
static readonly HashSet<T[]> inPool = new HashSet<T[]>();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Returns an array with at least the specified length.
|
||||
/// Warning: Returned arrays may contain arbitrary data.
|
||||
/// You cannot rely on it being zeroed out.
|
||||
///
|
||||
/// The returned array will always be a power of two, or zero.
|
||||
/// </summary>
|
||||
public static T[] Claim (int minimumLength) {
|
||||
if (minimumLength <= 0) {
|
||||
return ClaimWithExactLength(0);
|
||||
}
|
||||
|
||||
int bucketIndex = 0;
|
||||
while ((1 << bucketIndex) < minimumLength && bucketIndex < 30) {
|
||||
bucketIndex++;
|
||||
}
|
||||
|
||||
if (bucketIndex == 30)
|
||||
throw new System.ArgumentException("Too high minimum length");
|
||||
|
||||
#if !ASTAR_NO_POOLING
|
||||
lock (pool) {
|
||||
if (pool[bucketIndex] == null) {
|
||||
pool[bucketIndex] = new Stack<T[]>();
|
||||
}
|
||||
|
||||
if (pool[bucketIndex].Count > 0) {
|
||||
var array = pool[bucketIndex].Pop();
|
||||
#if !ASTAR_OPTIMIZE_POOLING
|
||||
inPool.Remove(array);
|
||||
#endif
|
||||
return array;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return new T[1 << bucketIndex];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns an array with the specified length.
|
||||
/// Use with caution as pooling too many arrays with different lengths that
|
||||
/// are rarely being reused will lead to an effective memory leak.
|
||||
///
|
||||
/// Use <see cref="Claim"/> if you just need an array that is at least as large as some value.
|
||||
///
|
||||
/// Warning: Returned arrays may contain arbitrary data.
|
||||
/// You cannot rely on it being zeroed out.
|
||||
/// </summary>
|
||||
public static T[] ClaimWithExactLength (int length) {
|
||||
#if !ASTAR_NO_POOLING
|
||||
bool isPowerOfTwo = length != 0 && (length & (length - 1)) == 0;
|
||||
if (isPowerOfTwo) {
|
||||
// Will return the correct array length
|
||||
return Claim(length);
|
||||
}
|
||||
|
||||
if (length <= MaximumExactArrayLength) {
|
||||
lock (pool) {
|
||||
Stack<T[]> stack = exactPool[length];
|
||||
if (stack != null && stack.Count > 0) {
|
||||
var array = stack.Pop();
|
||||
#if !ASTAR_OPTIMIZE_POOLING
|
||||
inPool.Remove(array);
|
||||
#endif
|
||||
return array;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return new T[length];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Pool an array.
|
||||
/// If the array was got using the <see cref="ClaimWithExactLength"/> method then the allowNonPowerOfTwo parameter must be set to true.
|
||||
/// The parameter exists to make sure that non power of two arrays are not pooled unintentionally which could lead to memory leaks.
|
||||
/// </summary>
|
||||
public static void Release (ref T[] array, bool allowNonPowerOfTwo = false) {
|
||||
if (array == null) return;
|
||||
if (array.GetType() != typeof(T[])) {
|
||||
throw new System.ArgumentException("Expected array type " + typeof(T[]).Name + " but found " + array.GetType().Name + "\nAre you using the correct generic class?\n");
|
||||
}
|
||||
|
||||
#if !ASTAR_NO_POOLING
|
||||
bool isPowerOfTwo = array.Length != 0 && (array.Length & (array.Length - 1)) == 0;
|
||||
if (!isPowerOfTwo && !allowNonPowerOfTwo && array.Length != 0) throw new System.ArgumentException("Length is not a power of 2");
|
||||
|
||||
lock (pool) {
|
||||
#if !ASTAR_OPTIMIZE_POOLING
|
||||
if (!inPool.Add(array)) {
|
||||
throw new InvalidOperationException("You are trying to pool an array twice. Please make sure that you only pool it once.");
|
||||
}
|
||||
#endif
|
||||
if (isPowerOfTwo) {
|
||||
int bucketIndex = 0;
|
||||
while ((1 << bucketIndex) < array.Length && bucketIndex < 30) {
|
||||
bucketIndex++;
|
||||
}
|
||||
|
||||
if (pool[bucketIndex] == null) {
|
||||
pool[bucketIndex] = new Stack<T[]>();
|
||||
}
|
||||
|
||||
pool[bucketIndex].Push(array);
|
||||
} else if (array.Length <= MaximumExactArrayLength) {
|
||||
Stack<T[]> stack = exactPool[array.Length];
|
||||
if (stack == null) stack = exactPool[array.Length] = new Stack<T[]>();
|
||||
stack.Push(array);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
array = null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Extension methods for List<T></summary>
|
||||
public static class ListExtensions {
|
||||
/// <summary>
|
||||
/// Identical to ToArray but it uses ArrayPool<T> to avoid allocations if possible.
|
||||
///
|
||||
/// Use with caution as pooling too many arrays with different lengths that
|
||||
/// are rarely being reused will lead to an effective memory leak.
|
||||
/// </summary>
|
||||
public static T[] ToArrayFromPool<T>(this List<T> list) {
|
||||
var arr = ArrayPool<T>.ClaimWithExactLength(list.Count);
|
||||
|
||||
for (int i = 0; i < arr.Length; i++) {
|
||||
arr[i] = list[i];
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clear a list faster than List<T>.Clear.
|
||||
/// It turns out that the List<T>.Clear method will clear all elements in the underlaying array
|
||||
/// not just the ones up to Count. If the list only has a few elements, but the capacity
|
||||
/// is huge, this can cause performance problems. Using the RemoveRange method to remove
|
||||
/// all elements in the list does not have this problem, however it is implemented in a
|
||||
/// stupid way, so it will clear the elements twice (completely unnecessarily) so it will
|
||||
/// only be faster than using the Clear method if the number of elements in the list is
|
||||
/// less than half of the capacity of the list.
|
||||
///
|
||||
/// Hopefully this method can be removed when Unity upgrades to a newer version of Mono.
|
||||
/// </summary>
|
||||
public static void ClearFast<T>(this List<T> list) {
|
||||
if (list.Count*2 < list.Capacity) {
|
||||
list.RemoveRange(0, list.Count);
|
||||
} else {
|
||||
list.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 787a564bf2d894ee09284b775074864c
|
||||
timeCreated: 1470483941
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,344 @@
|
||||
//#define ProfileAstar
|
||||
|
||||
using UnityEngine;
|
||||
using System.Text;
|
||||
|
||||
namespace Pathfinding {
|
||||
[AddComponentMenu("Pathfinding/Pathfinding Debugger")]
|
||||
[ExecuteInEditMode]
|
||||
/// <summary>
|
||||
/// Debugger for the A* Pathfinding Project.
|
||||
/// This class can be used to profile different parts of the pathfinding system
|
||||
/// and the whole game as well to some extent.
|
||||
///
|
||||
/// Clarification of the labels shown when enabled.
|
||||
/// All memory related things profiles <b>the whole game</b> not just the A* Pathfinding System.
|
||||
/// - Currently allocated: memory the GC (garbage collector) says the application has allocated right now.
|
||||
/// - Peak allocated: maximum measured value of the above.
|
||||
/// - Last collect peak: the last peak of 'currently allocated'.
|
||||
/// - Allocation rate: how much the 'currently allocated' value increases per second. This value is not as reliable as you can think
|
||||
/// it is often very random probably depending on how the GC thinks this application is using memory.
|
||||
/// - Collection frequency: how often the GC is called. Again, the GC might decide it is better with many small collections
|
||||
/// or with a few large collections. So you cannot really trust this variable much.
|
||||
/// - Last collect fps: FPS during the last garbage collection, the GC will lower the fps a lot.
|
||||
///
|
||||
/// - FPS: current FPS (not updated every frame for readability)
|
||||
/// - Lowest FPS (last x): As the label says, the lowest fps of the last x frames.
|
||||
///
|
||||
/// - Size: Size of the path pool.
|
||||
/// - Total created: Number of paths of that type which has been created. Pooled paths are not counted twice.
|
||||
/// If this value just keeps on growing and growing without an apparent stop, you are are either not pooling any paths
|
||||
/// or you have missed to pool some path somewhere in your code.
|
||||
///
|
||||
/// See: pooling
|
||||
///
|
||||
/// TODO: Add field showing how many graph updates are being done right now
|
||||
/// </summary>
|
||||
[HelpURL("http://arongranberg.com/astar/documentation/stable/class_pathfinding_1_1_astar_debugger.php")]
|
||||
public class AstarDebugger : VersionedMonoBehaviour {
|
||||
public int yOffset = 5;
|
||||
|
||||
public bool show = true;
|
||||
public bool showInEditor = false;
|
||||
|
||||
public bool showFPS = false;
|
||||
public bool showPathProfile = false;
|
||||
public bool showMemProfile = false;
|
||||
public bool showGraph = false;
|
||||
|
||||
public int graphBufferSize = 200;
|
||||
|
||||
/// <summary>
|
||||
/// Font to use.
|
||||
/// A monospaced font is the best
|
||||
/// </summary>
|
||||
public Font font = null;
|
||||
public int fontSize = 12;
|
||||
|
||||
StringBuilder text = new StringBuilder();
|
||||
string cachedText;
|
||||
float lastUpdate = -999;
|
||||
|
||||
private GraphPoint[] graph;
|
||||
|
||||
struct GraphPoint {
|
||||
public float fps, memory;
|
||||
public bool collectEvent;
|
||||
}
|
||||
|
||||
private float delayedDeltaTime = 1;
|
||||
private float lastCollect = 0;
|
||||
private float lastCollectNum = 0;
|
||||
private float delta = 0;
|
||||
private float lastDeltaTime = 0;
|
||||
private int allocRate = 0;
|
||||
private int lastAllocMemory = 0;
|
||||
private float lastAllocSet = -9999;
|
||||
private int allocMem = 0;
|
||||
private int collectAlloc = 0;
|
||||
private int peakAlloc = 0;
|
||||
|
||||
private int fpsDropCounterSize = 200;
|
||||
private float[] fpsDrops;
|
||||
|
||||
private Rect boxRect;
|
||||
|
||||
private GUIStyle style;
|
||||
|
||||
private Camera cam;
|
||||
|
||||
float graphWidth = 100;
|
||||
float graphHeight = 100;
|
||||
float graphOffset = 50;
|
||||
|
||||
public void Start () {
|
||||
useGUILayout = false;
|
||||
|
||||
fpsDrops = new float[fpsDropCounterSize];
|
||||
|
||||
cam = GetComponent<Camera>();
|
||||
if (cam == null) {
|
||||
cam = Camera.main;
|
||||
}
|
||||
|
||||
graph = new GraphPoint[graphBufferSize];
|
||||
|
||||
if (Time.unscaledDeltaTime > 0) {
|
||||
for (int i = 0; i < fpsDrops.Length; i++) {
|
||||
fpsDrops[i] = 1F / Time.unscaledDeltaTime;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int maxVecPool = 0;
|
||||
int maxNodePool = 0;
|
||||
|
||||
PathTypeDebug[] debugTypes = new PathTypeDebug[] {
|
||||
new PathTypeDebug("ABPath", () => PathPool.GetSize(typeof(ABPath)), () => PathPool.GetTotalCreated(typeof(ABPath)))
|
||||
,
|
||||
new PathTypeDebug("MultiTargetPath", () => PathPool.GetSize(typeof(MultiTargetPath)), () => PathPool.GetTotalCreated(typeof(MultiTargetPath))),
|
||||
new PathTypeDebug("RandomPath", () => PathPool.GetSize(typeof(RandomPath)), () => PathPool.GetTotalCreated(typeof(RandomPath))),
|
||||
new PathTypeDebug("FleePath", () => PathPool.GetSize(typeof(FleePath)), () => PathPool.GetTotalCreated(typeof(FleePath))),
|
||||
new PathTypeDebug("ConstantPath", () => PathPool.GetSize(typeof(ConstantPath)), () => PathPool.GetTotalCreated(typeof(ConstantPath))),
|
||||
new PathTypeDebug("FloodPath", () => PathPool.GetSize(typeof(FloodPath)), () => PathPool.GetTotalCreated(typeof(FloodPath))),
|
||||
new PathTypeDebug("FloodPathTracer", () => PathPool.GetSize(typeof(FloodPathTracer)), () => PathPool.GetTotalCreated(typeof(FloodPathTracer)))
|
||||
};
|
||||
|
||||
struct PathTypeDebug {
|
||||
string name;
|
||||
System.Func<int> getSize;
|
||||
System.Func<int> getTotalCreated;
|
||||
public PathTypeDebug (string name, System.Func<int> getSize, System.Func<int> getTotalCreated) {
|
||||
this.name = name;
|
||||
this.getSize = getSize;
|
||||
this.getTotalCreated = getTotalCreated;
|
||||
}
|
||||
|
||||
public void Print (StringBuilder text) {
|
||||
int totCreated = getTotalCreated();
|
||||
|
||||
if (totCreated > 0) {
|
||||
text.Append("\n").Append((" " + name).PadRight(25)).Append(getSize()).Append("/").Append(totCreated);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void LateUpdate () {
|
||||
if (!show || (!Application.isPlaying && !showInEditor)) return;
|
||||
|
||||
if (Time.unscaledDeltaTime <= 0.0001f)
|
||||
return;
|
||||
|
||||
int collCount = System.GC.CollectionCount(0);
|
||||
|
||||
if (lastCollectNum != collCount) {
|
||||
lastCollectNum = collCount;
|
||||
delta = Time.realtimeSinceStartup-lastCollect;
|
||||
lastCollect = Time.realtimeSinceStartup;
|
||||
lastDeltaTime = Time.unscaledDeltaTime;
|
||||
collectAlloc = allocMem;
|
||||
}
|
||||
|
||||
allocMem = (int)System.GC.GetTotalMemory(false);
|
||||
|
||||
bool collectEvent = allocMem < peakAlloc;
|
||||
peakAlloc = !collectEvent ? allocMem : peakAlloc;
|
||||
|
||||
if (Time.realtimeSinceStartup - lastAllocSet > 0.3F || !Application.isPlaying) {
|
||||
int diff = allocMem - lastAllocMemory;
|
||||
lastAllocMemory = allocMem;
|
||||
lastAllocSet = Time.realtimeSinceStartup;
|
||||
delayedDeltaTime = Time.unscaledDeltaTime;
|
||||
|
||||
if (diff >= 0) {
|
||||
allocRate = diff;
|
||||
}
|
||||
}
|
||||
|
||||
if (Application.isPlaying) {
|
||||
fpsDrops[Time.frameCount % fpsDrops.Length] = Time.unscaledDeltaTime > 0.00001f ? 1F / Time.unscaledDeltaTime : 0;
|
||||
int graphIndex = Time.frameCount % graph.Length;
|
||||
graph[graphIndex].fps = Time.unscaledDeltaTime < 0.00001f ? 1F / Time.unscaledDeltaTime : 0;
|
||||
graph[graphIndex].collectEvent = collectEvent;
|
||||
graph[graphIndex].memory = allocMem;
|
||||
}
|
||||
|
||||
if (Application.isPlaying && cam != null && showGraph) {
|
||||
graphWidth = cam.pixelWidth*0.8f;
|
||||
|
||||
|
||||
float minMem = float.PositiveInfinity, maxMem = 0, minFPS = float.PositiveInfinity, maxFPS = 0;
|
||||
for (int i = 0; i < graph.Length; i++) {
|
||||
minMem = Mathf.Min(graph[i].memory, minMem);
|
||||
maxMem = Mathf.Max(graph[i].memory, maxMem);
|
||||
minFPS = Mathf.Min(graph[i].fps, minFPS);
|
||||
maxFPS = Mathf.Max(graph[i].fps, maxFPS);
|
||||
}
|
||||
|
||||
int currentGraphIndex = Time.frameCount % graph.Length;
|
||||
|
||||
Matrix4x4 m = Matrix4x4.TRS(new Vector3((cam.pixelWidth - graphWidth)/2f, graphOffset, 1), Quaternion.identity, new Vector3(graphWidth, graphHeight, 1));
|
||||
|
||||
for (int i = 0; i < graph.Length-1; i++) {
|
||||
if (i == currentGraphIndex) continue;
|
||||
|
||||
DrawGraphLine(i, m, i/(float)graph.Length, (i+1)/(float)graph.Length, Mathf.InverseLerp(minMem, maxMem, graph[i].memory), Mathf.InverseLerp(minMem, maxMem, graph[i+1].memory), Color.blue);
|
||||
DrawGraphLine(i, m, i/(float)graph.Length, (i+1)/(float)graph.Length, Mathf.InverseLerp(minFPS, maxFPS, graph[i].fps), Mathf.InverseLerp(minFPS, maxFPS, graph[i+1].fps), Color.green);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DrawGraphLine (int index, Matrix4x4 m, float x1, float x2, float y1, float y2, Color color) {
|
||||
Debug.DrawLine(cam.ScreenToWorldPoint(m.MultiplyPoint3x4(new Vector3(x1, y1))), cam.ScreenToWorldPoint(m.MultiplyPoint3x4(new Vector3(x2, y2))), color);
|
||||
}
|
||||
|
||||
public void OnGUI () {
|
||||
if (!show || (!Application.isPlaying && !showInEditor)) return;
|
||||
|
||||
if (style == null) {
|
||||
style = new GUIStyle();
|
||||
style.normal.textColor = Color.white;
|
||||
style.padding = new RectOffset(5, 5, 5, 5);
|
||||
}
|
||||
|
||||
if (Time.realtimeSinceStartup - lastUpdate > 0.5f || cachedText == null || !Application.isPlaying) {
|
||||
lastUpdate = Time.realtimeSinceStartup;
|
||||
|
||||
boxRect = new Rect(5, yOffset, 310, 40);
|
||||
|
||||
text.Length = 0;
|
||||
text.AppendLine("A* Pathfinding Project Debugger");
|
||||
text.Append("A* Version: ").Append(AstarPath.Version.ToString());
|
||||
|
||||
if (showMemProfile) {
|
||||
boxRect.height += 200;
|
||||
|
||||
text.AppendLine();
|
||||
text.AppendLine();
|
||||
text.Append("Currently allocated".PadRight(25));
|
||||
text.Append((allocMem/1000000F).ToString("0.0 MB"));
|
||||
text.AppendLine();
|
||||
|
||||
text.Append("Peak allocated".PadRight(25));
|
||||
text.Append((peakAlloc/1000000F).ToString("0.0 MB")).AppendLine();
|
||||
|
||||
text.Append("Last collect peak".PadRight(25));
|
||||
text.Append((collectAlloc/1000000F).ToString("0.0 MB")).AppendLine();
|
||||
|
||||
|
||||
text.Append("Allocation rate".PadRight(25));
|
||||
text.Append((allocRate/1000000F).ToString("0.0 MB")).AppendLine();
|
||||
|
||||
text.Append("Collection frequency".PadRight(25));
|
||||
text.Append(delta.ToString("0.00"));
|
||||
text.Append("s\n");
|
||||
|
||||
text.Append("Last collect fps".PadRight(25));
|
||||
text.Append((1F/lastDeltaTime).ToString("0.0 fps"));
|
||||
text.Append(" (");
|
||||
text.Append(lastDeltaTime.ToString("0.000 s"));
|
||||
text.Append(")");
|
||||
}
|
||||
|
||||
if (showFPS) {
|
||||
text.AppendLine();
|
||||
text.AppendLine();
|
||||
var delayedFPS = delayedDeltaTime > 0.00001f ? 1F/delayedDeltaTime : 0;
|
||||
text.Append("FPS".PadRight(25)).Append(delayedFPS.ToString("0.0 fps"));
|
||||
|
||||
|
||||
float minFps = Mathf.Infinity;
|
||||
|
||||
for (int i = 0; i < fpsDrops.Length; i++) if (fpsDrops[i] < minFps) minFps = fpsDrops[i];
|
||||
|
||||
text.AppendLine();
|
||||
text.Append(("Lowest fps (last " + fpsDrops.Length + ")").PadRight(25)).Append(minFps.ToString("0.0"));
|
||||
}
|
||||
|
||||
if (showPathProfile) {
|
||||
AstarPath astar = AstarPath.active;
|
||||
|
||||
text.AppendLine();
|
||||
|
||||
if (astar == null) {
|
||||
text.Append("\nNo AstarPath Object In The Scene");
|
||||
} else {
|
||||
#if ProfileAstar
|
||||
double searchSpeed = (double)AstarPath.TotalSearchedNodes*10000 / (double)AstarPath.TotalSearchTime;
|
||||
text.Append("\nSearch Speed (nodes/ms) ").Append(searchSpeed.ToString("0")).Append(" ("+AstarPath.TotalSearchedNodes+" / ").Append(((double)AstarPath.TotalSearchTime/10000F).ToString("0")+")");
|
||||
#endif
|
||||
|
||||
if (Pathfinding.Util.ListPool<Vector3>.GetSize() > maxVecPool) maxVecPool = Pathfinding.Util.ListPool<Vector3>.GetSize();
|
||||
if (Pathfinding.Util.ListPool<Pathfinding.GraphNode>.GetSize() > maxNodePool) maxNodePool = Pathfinding.Util.ListPool<Pathfinding.GraphNode>.GetSize();
|
||||
|
||||
text.Append("\nPool Sizes (size/total created)");
|
||||
|
||||
for (int i = 0; i < debugTypes.Length; i++) {
|
||||
debugTypes[i].Print(text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cachedText = text.ToString();
|
||||
}
|
||||
|
||||
|
||||
if (font != null) {
|
||||
style.font = font;
|
||||
style.fontSize = fontSize;
|
||||
}
|
||||
|
||||
boxRect.height = style.CalcHeight(new GUIContent(cachedText), boxRect.width);
|
||||
|
||||
GUI.Box(boxRect, "");
|
||||
GUI.Label(boxRect, cachedText, style);
|
||||
|
||||
if (showGraph) {
|
||||
float minMem = float.PositiveInfinity, maxMem = 0, minFPS = float.PositiveInfinity, maxFPS = 0;
|
||||
for (int i = 0; i < graph.Length; i++) {
|
||||
minMem = Mathf.Min(graph[i].memory, minMem);
|
||||
maxMem = Mathf.Max(graph[i].memory, maxMem);
|
||||
minFPS = Mathf.Min(graph[i].fps, minFPS);
|
||||
maxFPS = Mathf.Max(graph[i].fps, maxFPS);
|
||||
}
|
||||
|
||||
float line;
|
||||
GUI.color = Color.blue;
|
||||
// Round to nearest x.x MB
|
||||
line = Mathf.RoundToInt(maxMem/(100.0f*1000));
|
||||
GUI.Label(new Rect(5, Screen.height - AstarMath.MapTo(minMem, maxMem, 0 + graphOffset, graphHeight + graphOffset, line*1000*100) - 10, 100, 20), (line/10.0f).ToString("0.0 MB"));
|
||||
|
||||
line = Mathf.Round(minMem/(100.0f*1000));
|
||||
GUI.Label(new Rect(5, Screen.height - AstarMath.MapTo(minMem, maxMem, 0 + graphOffset, graphHeight + graphOffset, line*1000*100) - 10, 100, 20), (line/10.0f).ToString("0.0 MB"));
|
||||
|
||||
GUI.color = Color.green;
|
||||
// Round to nearest x.x MB
|
||||
line = Mathf.Round(maxFPS);
|
||||
GUI.Label(new Rect(55, Screen.height - AstarMath.MapTo(minFPS, maxFPS, 0 + graphOffset, graphHeight + graphOffset, line) - 10, 100, 20), line.ToString("0 FPS"));
|
||||
|
||||
line = Mathf.Round(minFPS);
|
||||
GUI.Label(new Rect(55, Screen.height - AstarMath.MapTo(minFPS, maxFPS, 0 + graphOffset, graphHeight + graphOffset, line) - 10, 100, 20), line.ToString("0 FPS"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5103795af2d504ea693528e938005441
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user