Fantastic map#1
This commit is contained in:
3
Assets/Scripts/Animators.meta
generated
Normal file
3
Assets/Scripts/Animators.meta
generated
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0cf97b021cee45eb8f7d402f16955139
|
||||
timeCreated: 1652022637
|
3
Assets/Scripts/Animators/Kirill Animator.meta
generated
Normal file
3
Assets/Scripts/Animators/Kirill Animator.meta
generated
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 97bb456bbc4248378002eefeb52be6c3
|
||||
timeCreated: 1652022665
|
@ -1,23 +1,13 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Unity.Barracuda;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
using static scr_Models;
|
||||
using UnityEngine;
|
||||
|
||||
public class scr_CharacterController : MonoBehaviour
|
||||
{
|
||||
|
||||
private CharacterController characterController;
|
||||
private DefaultInput defaultInput;
|
||||
|
||||
[HideInInspector]
|
||||
public Vector2 input_Movement;
|
||||
private Vector2 input_Movement;
|
||||
[HideInInspector]
|
||||
public Vector2 input_View;
|
||||
|
||||
|
||||
private Vector3 newCameraRotation;
|
||||
private Vector3 newCharacterRotation;
|
||||
|
||||
@ -25,14 +15,14 @@ public class scr_CharacterController : MonoBehaviour
|
||||
public Transform cameraHolder;
|
||||
public Transform feetTransform;
|
||||
|
||||
[Header("Settings")]
|
||||
[Header("Settings")]
|
||||
public PlayerSettingsModel playerSettings;
|
||||
|
||||
public float ViewClampYMin = -70;
|
||||
public float ViewClampYMax = 80;
|
||||
public LayerMask playerMask;
|
||||
|
||||
[Header("Gravity")]
|
||||
|
||||
[Header("Gravity")]
|
||||
public float gravityAmount;
|
||||
public float gravityMin;
|
||||
private float playerGravity;
|
||||
@ -40,36 +30,24 @@ public class scr_CharacterController : MonoBehaviour
|
||||
public Vector3 jumpingForce;
|
||||
private Vector3 jumpingForceVelocity;
|
||||
|
||||
[Header("Stance")]
|
||||
[Header("Stance")]
|
||||
public PlayerStance playerStance;
|
||||
public float playerStanceSmoothing;
|
||||
public CharacterStance playerStandStance;
|
||||
public CharacterStance playerCrouchStance;
|
||||
public CharacterStance playerProneStance;
|
||||
private float stanceCheckErrorMargin = 0.05f;
|
||||
|
||||
|
||||
private float cameraHeight;
|
||||
private float cameraHeightVelocity;
|
||||
|
||||
[HideInInspector]
|
||||
public bool isSprinting;
|
||||
public bool isWalking;
|
||||
private bool isSprinting;
|
||||
|
||||
private Vector3 newMovementSpeed;
|
||||
private Vector3 newMovementSpeedVelocity;
|
||||
|
||||
//[Header("Weapon")]
|
||||
[HideInInspector]
|
||||
[Header("Weapon")]
|
||||
public scr_WeaponController currentWeapon;
|
||||
|
||||
public float weaponAnimationSpeed;
|
||||
|
||||
public float damage = 10f;
|
||||
public float range = 100f;
|
||||
|
||||
public Camera fpsCam;
|
||||
public ParticleSystem muzzleFlash;
|
||||
public GameObject impactEffect;
|
||||
private void Awake()
|
||||
{
|
||||
defaultInput = new DefaultInput();
|
||||
@ -77,13 +55,13 @@ public class scr_CharacterController : MonoBehaviour
|
||||
defaultInput.Character.Movement.performed += e => input_Movement = e.ReadValue<Vector2>();
|
||||
defaultInput.Character.View.performed += e => input_View = e.ReadValue<Vector2>();
|
||||
defaultInput.Character.Jump.performed += e => Jump();
|
||||
|
||||
|
||||
defaultInput.Character.Crouch.performed += e => Crouch();
|
||||
defaultInput.Character.Prone.performed += e => Prone();
|
||||
|
||||
|
||||
defaultInput.Character.Sprint.performed += e => ToggleSprint();
|
||||
defaultInput.Character.SprintReleased.performed += e => StopSprint();
|
||||
|
||||
|
||||
defaultInput.Enable();
|
||||
|
||||
newCameraRotation = cameraHolder.localRotation.eulerAngles;
|
||||
@ -91,66 +69,40 @@ public class scr_CharacterController : MonoBehaviour
|
||||
characterController = GetComponent<CharacterController>();
|
||||
|
||||
cameraHeight = cameraHolder.localPosition.y;
|
||||
/*
|
||||
|
||||
if (currentWeapon)
|
||||
{
|
||||
currentWeapon.Initialise(this);
|
||||
}*/
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (Input.GetButtonDown("Fire1"))
|
||||
{
|
||||
Shoot();
|
||||
}
|
||||
CalculateView();
|
||||
CalculateMovement();
|
||||
CalculateJump();
|
||||
CalculateCameraHeight();
|
||||
}
|
||||
|
||||
void Shoot()
|
||||
{
|
||||
muzzleFlash.Play();
|
||||
RaycastHit hit;
|
||||
if (Physics.Raycast(fpsCam.transform.position, fpsCam.transform.forward, out hit, range))
|
||||
{
|
||||
Debug.Log(hit.transform.name);
|
||||
|
||||
Target target = hit.transform.GetComponent<Target>();
|
||||
if (target != null)
|
||||
{
|
||||
target.TakeDamage(damage);
|
||||
}
|
||||
|
||||
Instantiate(impactEffect, hit.point, Quaternion.LookRotation(hit.normal));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void CalculateView()
|
||||
{
|
||||
newCharacterRotation.y += playerSettings.ViewXSensetivity * (playerSettings.ViewXInverted ? -input_View.x : input_View.x) * Time.deltaTime;
|
||||
transform.localRotation = Quaternion.Euler(newCharacterRotation);
|
||||
|
||||
|
||||
newCameraRotation.x += playerSettings.ViewYSensetivity * (playerSettings.ViewYInverted ? input_View.y : -input_View.y) * Time.deltaTime;
|
||||
newCameraRotation.x = Mathf.Clamp(newCameraRotation.x, ViewClampYMin, ViewClampYMax);
|
||||
|
||||
|
||||
cameraHolder.localRotation = Quaternion.Euler(newCameraRotation);
|
||||
}
|
||||
|
||||
private void CalculateMovement()
|
||||
{
|
||||
if (input_Movement.y <= 0.3f)
|
||||
if (input_Movement.y <= 0.2f)
|
||||
{
|
||||
isSprinting = false;
|
||||
}
|
||||
if (input_Movement.y <= 0.2f && input_Movement.y <= 0.3f)
|
||||
{
|
||||
isWalking = false;
|
||||
}
|
||||
|
||||
var verticalSpeed = playerSettings.WalkingForwardSpeed;
|
||||
var horizontalSpeed = playerSettings.WalkingStrafeSpeed;
|
||||
|
||||
@ -159,18 +111,17 @@ public class scr_CharacterController : MonoBehaviour
|
||||
verticalSpeed = playerSettings.RunningForwardSpeed;
|
||||
horizontalSpeed = playerSettings.RunningStrafeSpeed;
|
||||
}
|
||||
|
||||
|
||||
// Effectors
|
||||
|
||||
if (!characterController.isGrounded)
|
||||
{
|
||||
playerSettings.SpeedEffector = playerSettings.FallingSpeedEffector;
|
||||
}
|
||||
else if(playerStance == PlayerStance.Crouch)
|
||||
else if (playerStance == PlayerStance.Crouch)
|
||||
{
|
||||
playerSettings.SpeedEffector = playerSettings.CrouchSpeedEffector;
|
||||
}
|
||||
else if(playerStance == PlayerStance.Prone)
|
||||
}
|
||||
else if (playerStance == PlayerStance.Prone)
|
||||
{
|
||||
playerSettings.SpeedEffector = playerSettings.ProneSpeedEffector;
|
||||
}
|
||||
@ -178,22 +129,15 @@ public class scr_CharacterController : MonoBehaviour
|
||||
{
|
||||
playerSettings.SpeedEffector = 1;
|
||||
}
|
||||
|
||||
weaponAnimationSpeed = characterController.velocity.magnitude / (playerSettings.WalkingForwardSpeed * playerSettings.SpeedEffector);
|
||||
|
||||
if (weaponAnimationSpeed > 1)
|
||||
{
|
||||
weaponAnimationSpeed = 1;
|
||||
}
|
||||
|
||||
verticalSpeed *= playerSettings.SpeedEffector;
|
||||
horizontalSpeed *= playerSettings.SpeedEffector;
|
||||
|
||||
|
||||
newMovementSpeed = Vector3.SmoothDamp(newMovementSpeed,
|
||||
new Vector3(horizontalSpeed * input_Movement.x * Time.deltaTime,
|
||||
0, verticalSpeed * input_Movement.y * Time.deltaTime),
|
||||
ref newMovementSpeedVelocity, characterController.isGrounded ? playerSettings.MovementSmoothing : playerSettings.FallingSmoothing);
|
||||
|
||||
|
||||
var MovementSpeed = transform.TransformDirection(newMovementSpeed);
|
||||
|
||||
if (playerGravity > gravityMin)
|
||||
@ -208,7 +152,7 @@ public class scr_CharacterController : MonoBehaviour
|
||||
|
||||
MovementSpeed.y += playerGravity;
|
||||
MovementSpeed += jumpingForce * Time.deltaTime;
|
||||
|
||||
|
||||
characterController.Move(MovementSpeed);
|
||||
}
|
||||
|
||||
@ -229,7 +173,7 @@ public class scr_CharacterController : MonoBehaviour
|
||||
{
|
||||
stanceHeight = playerProneStance.CameraHeight;
|
||||
}
|
||||
|
||||
|
||||
cameraHeight = Mathf.SmoothDamp(cameraHolder.localPosition.y, stanceHeight, ref cameraHeightVelocity, playerStanceSmoothing);
|
||||
|
||||
cameraHolder.localPosition = new Vector3(cameraHolder.localPosition.x, cameraHeight, cameraHolder.localPosition.z);
|
||||
@ -240,7 +184,7 @@ public class scr_CharacterController : MonoBehaviour
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (playerStance == PlayerStance.Crouch)
|
||||
{
|
||||
if (StanceCheck(playerStandStance.StanceCollider.height))
|
||||
@ -250,7 +194,7 @@ public class scr_CharacterController : MonoBehaviour
|
||||
playerStance = PlayerStance.Stand;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Jump
|
||||
jumpingForce = Vector3.up * playerSettings.JumpingHeight;
|
||||
playerGravity = 0;
|
||||
@ -283,8 +227,8 @@ public class scr_CharacterController : MonoBehaviour
|
||||
{
|
||||
var start = new Vector3(feetTransform.position.x, feetTransform.position.y + characterController.radius + stanceCheckErrorMargin, feetTransform.position.z);
|
||||
var end = new Vector3(feetTransform.position.x, feetTransform.position.y - characterController.radius - stanceCheckErrorMargin + stanceCheckheight, feetTransform.position.z);
|
||||
|
||||
|
||||
|
||||
|
||||
return Physics.CheckCapsule(start, end, characterController.radius, playerMask);
|
||||
}
|
||||
|
||||
@ -297,7 +241,7 @@ public class scr_CharacterController : MonoBehaviour
|
||||
}
|
||||
isSprinting = !isSprinting;
|
||||
}
|
||||
|
||||
|
||||
private void StopSprint()
|
||||
{
|
||||
if (playerSettings.SprintingHold)
|
||||
@ -305,5 +249,5 @@ public class scr_CharacterController : MonoBehaviour
|
||||
isSprinting = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
0
Assets/Scripts/Character/scr_CharacterController.cs.meta → Assets/Scripts/Animators/Kirill Animator/CustomCharacterController.cs.meta
generated
Executable file → Normal file
0
Assets/Scripts/Character/scr_CharacterController.cs.meta → Assets/Scripts/Animators/Kirill Animator/CustomCharacterController.cs.meta
generated
Executable file → Normal file
67
Assets/Scripts/Animators/Kirill Animator/Models.cs
Normal file
67
Assets/Scripts/Animators/Kirill Animator/Models.cs
Normal file
@ -0,0 +1,67 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
public enum PlayerStance
|
||||
{
|
||||
Stand,
|
||||
Crouch,
|
||||
Prone
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class PlayerSettingsModel
|
||||
{
|
||||
[Header("View Settings")]
|
||||
public float ViewXSensetivity;
|
||||
public float ViewYSensetivity;
|
||||
|
||||
public bool ViewXInverted;
|
||||
public bool ViewYInverted;
|
||||
|
||||
[Header("Movement Settings")]
|
||||
public bool SprintingHold;
|
||||
public float MovementSmoothing;
|
||||
|
||||
[Header("Movement - Running")]
|
||||
public float RunningForwardSpeed;
|
||||
public float RunningStrafeSpeed;
|
||||
|
||||
[Header("Movement - Walking")]
|
||||
public float WalkingForwardSpeed;
|
||||
public float WalkingBackwardSpeed;
|
||||
public float WalkingStrafeSpeed;
|
||||
|
||||
[Header("Jumping")]
|
||||
public float JumpingHeight;
|
||||
public float JumpingFalloff;
|
||||
public float FallingSmoothing;
|
||||
|
||||
[Header("Speed Effectors")]
|
||||
public float SpeedEffector = 1;
|
||||
public float CrouchSpeedEffector;
|
||||
public float ProneSpeedEffector;
|
||||
public float FallingSpeedEffector;
|
||||
}
|
||||
|
||||
|
||||
[Serializable]
|
||||
public class CharacterStance
|
||||
{
|
||||
public float CameraHeight;
|
||||
public CapsuleCollider StanceCollider;
|
||||
}
|
||||
|
||||
|
||||
[Serializable]
|
||||
public class WeaponSettingsModel
|
||||
{
|
||||
[Header("Sway")]
|
||||
public float SwayAmount;
|
||||
public bool SwayYInverted;
|
||||
public bool SwayXInverted;
|
||||
public float SwaySmoothing;
|
||||
public float SwayResetSmoothing;
|
||||
public float SwayClampX;
|
||||
public float SwayClampY;
|
||||
}
|
2
Assets/Scripts/Sensors/SensorType.cs.meta → Assets/Scripts/Animators/Kirill Animator/Models.cs.meta
generated
Executable file → Normal file
2
Assets/Scripts/Sensors/SensorType.cs.meta → Assets/Scripts/Animators/Kirill Animator/Models.cs.meta
generated
Executable file → Normal file
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8f76201fe6436164789d10350a0fd6e2
|
||||
guid: 8fe13ad8c6843804c97b783914bc27b3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
3
Assets/Scripts/Animators/Leonid Animator.meta
generated
Normal file
3
Assets/Scripts/Animators/Leonid Animator.meta
generated
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2cc90c830ef641a1a18e8e21dc97dec0
|
||||
timeCreated: 1652022681
|
94
Assets/Scripts/Animators/Leonid Animator/AnimatorHandler.cs
Normal file
94
Assets/Scripts/Animators/Leonid Animator/AnimatorHandler.cs
Normal file
@ -0,0 +1,94 @@
|
||||
using Unity.Mathematics;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Animators.Leonid_Animator
|
||||
{
|
||||
public class AnimatorHandler : MonoBehaviour
|
||||
{
|
||||
public Animator anim;
|
||||
public bool canRotate;
|
||||
|
||||
private int _horizontal;
|
||||
private int _vertical;
|
||||
private bool _isCrouching = false;
|
||||
private bool _isJumping;
|
||||
|
||||
private int _crouch;
|
||||
private int _jump;
|
||||
private int _fired;
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
anim = GetComponent<Animator>();
|
||||
_vertical = Animator.StringToHash(nameof(_vertical));
|
||||
_horizontal = Animator.StringToHash(nameof(_horizontal));
|
||||
_crouch = Animator.StringToHash(nameof(_crouch));
|
||||
_jump = Animator.StringToHash(nameof(_jump));
|
||||
_fired = Animator.StringToHash(nameof(_fired));
|
||||
}
|
||||
|
||||
public void UpdateAnimatorValues(float verticalMovement, float horizontalMovement,
|
||||
bool pressedJumped, bool pressedCrouching, bool firePressed)
|
||||
{
|
||||
#region Vertical Movement
|
||||
|
||||
var vertical = 0f;
|
||||
if (verticalMovement > 0 && verticalMovement < 0.55)
|
||||
vertical = 0.5f;
|
||||
else if (verticalMovement > 0.55)
|
||||
vertical = 1;
|
||||
else if (verticalMovement < 0 && verticalMovement > -0.55)
|
||||
{
|
||||
vertical = -0.5f;
|
||||
}
|
||||
else if (verticalMovement < -0.55)
|
||||
{
|
||||
vertical = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
vertical = 0;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Vertical Movement
|
||||
|
||||
var horizontal = 0f;
|
||||
if (horizontalMovement > 0 && horizontalMovement < 0.55)
|
||||
horizontal = 0.5f;
|
||||
else if (horizontalMovement > 0.55)
|
||||
horizontal = 1;
|
||||
else if (horizontalMovement < 0 && horizontalMovement > -0.55)
|
||||
{
|
||||
horizontal = -0.5f;
|
||||
}
|
||||
else if (horizontalMovement < -0.55)
|
||||
{
|
||||
horizontal = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
horizontal = 0;
|
||||
}
|
||||
#endregion
|
||||
|
||||
anim.SetFloat(_horizontal, horizontal, 0.1f, Time.deltaTime);
|
||||
anim.SetFloat(_vertical, vertical, 0.1f, Time.deltaTime);
|
||||
|
||||
if (pressedCrouching == true)
|
||||
{
|
||||
_isCrouching = !_isCrouching;
|
||||
if (_isCrouching == true)
|
||||
transform.Rotate(Vector3.up, 45);
|
||||
else
|
||||
{
|
||||
transform.Rotate(Vector3.up, -45);
|
||||
}
|
||||
anim.SetBool(_crouch, _isCrouching);
|
||||
}
|
||||
|
||||
anim.SetBool(_jump, pressedJumped);
|
||||
anim.SetBool(_fired, firePressed);
|
||||
}
|
||||
}
|
||||
}
|
3
Assets/Scripts/Animators/Leonid Animator/AnimatorHandler.cs.meta
generated
Normal file
3
Assets/Scripts/Animators/Leonid Animator/AnimatorHandler.cs.meta
generated
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f9c5f555eb7641518e39a97abe893cd8
|
||||
timeCreated: 1652031215
|
@ -0,0 +1,905 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!1101 &-8614502741554326989
|
||||
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: _died
|
||||
m_EventTreshold: 0
|
||||
m_DstStateMachine: {fileID: 0}
|
||||
m_DstState: {fileID: -5023192667791512651}
|
||||
m_Solo: 0
|
||||
m_Mute: 0
|
||||
m_IsExit: 0
|
||||
serializedVersion: 3
|
||||
m_TransitionDuration: 0.46723264
|
||||
m_TransitionOffset: 0.21265899
|
||||
m_ExitTime: 0.57224524
|
||||
m_HasExitTime: 0
|
||||
m_HasFixedDuration: 1
|
||||
m_InterruptionSource: 0
|
||||
m_OrderedInterruption: 1
|
||||
m_CanTransitionToSelf: 1
|
||||
--- !u!1107 &-8265500127550764659
|
||||
AnimatorStateMachine:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Upper
|
||||
m_ChildStates:
|
||||
- serializedVersion: 1
|
||||
m_State: {fileID: -4600760231423422918}
|
||||
m_Position: {x: 340, y: 140, z: 0}
|
||||
- serializedVersion: 1
|
||||
m_State: {fileID: 7739110899394721029}
|
||||
m_Position: {x: 510, y: -10, z: 0}
|
||||
- serializedVersion: 1
|
||||
m_State: {fileID: -4187437994059944167}
|
||||
m_Position: {x: 400, y: 290, z: 0}
|
||||
- serializedVersion: 1
|
||||
m_State: {fileID: -5023192667791512651}
|
||||
m_Position: {x: 830, y: 130, z: 0}
|
||||
m_ChildStateMachines: []
|
||||
m_AnyStateTransitions: []
|
||||
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: 1150, y: 160, z: 0}
|
||||
m_ParentStateMachinePosition: {x: 800, y: 20, z: 0}
|
||||
m_DefaultState: {fileID: -4600760231423422918}
|
||||
--- !u!1101 &-6757359955429936644
|
||||
AnimatorStateTransition:
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Jump to Run
|
||||
m_Conditions: []
|
||||
m_DstStateMachine: {fileID: 0}
|
||||
m_DstState: {fileID: 8354844821256608690}
|
||||
m_Solo: 0
|
||||
m_Mute: 0
|
||||
m_IsExit: 0
|
||||
serializedVersion: 3
|
||||
m_TransitionDuration: 0.20300466
|
||||
m_TransitionOffset: 0
|
||||
m_ExitTime: 0.7916667
|
||||
m_HasExitTime: 1
|
||||
m_HasFixedDuration: 1
|
||||
m_InterruptionSource: 0
|
||||
m_OrderedInterruption: 1
|
||||
m_CanTransitionToSelf: 1
|
||||
--- !u!1101 &-6673604382440492192
|
||||
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: _fired
|
||||
m_EventTreshold: 0
|
||||
m_DstStateMachine: {fileID: 0}
|
||||
m_DstState: {fileID: -4187437994059944167}
|
||||
m_Solo: 0
|
||||
m_Mute: 0
|
||||
m_IsExit: 0
|
||||
serializedVersion: 3
|
||||
m_TransitionDuration: 1.2815269
|
||||
m_TransitionOffset: 0.04597427
|
||||
m_ExitTime: 0.009130422
|
||||
m_HasExitTime: 0
|
||||
m_HasFixedDuration: 1
|
||||
m_InterruptionSource: 0
|
||||
m_OrderedInterruption: 1
|
||||
m_CanTransitionToSelf: 1
|
||||
--- !u!1102 &-5914497066343941395
|
||||
AnimatorState:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Jump
|
||||
m_Speed: 1
|
||||
m_CycleOffset: 0
|
||||
m_Transitions:
|
||||
- {fileID: 5168308916736617153}
|
||||
- {fileID: 9141976730198879995}
|
||||
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: c09541f4236345c4fa4e4745793a59f3, type: 3}
|
||||
m_Tag:
|
||||
m_SpeedParameter:
|
||||
m_MirrorParameter:
|
||||
m_CycleOffsetParameter:
|
||||
m_TimeParameter:
|
||||
--- !u!1101 &-5341886129914063569
|
||||
AnimatorStateTransition:
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name:
|
||||
m_Conditions:
|
||||
- m_ConditionMode: 2
|
||||
m_ConditionEvent: _jump
|
||||
m_EventTreshold: 0
|
||||
m_DstStateMachine: {fileID: 0}
|
||||
m_DstState: {fileID: -4600760231423422918}
|
||||
m_Solo: 0
|
||||
m_Mute: 0
|
||||
m_IsExit: 0
|
||||
serializedVersion: 3
|
||||
m_TransitionDuration: 0.25
|
||||
m_TransitionOffset: 0
|
||||
m_ExitTime: 0.7916667
|
||||
m_HasExitTime: 1
|
||||
m_HasFixedDuration: 1
|
||||
m_InterruptionSource: 0
|
||||
m_OrderedInterruption: 1
|
||||
m_CanTransitionToSelf: 1
|
||||
--- !u!1102 &-5023192667791512651
|
||||
AnimatorState:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Die
|
||||
m_Speed: 1
|
||||
m_CycleOffset: 0
|
||||
m_Transitions:
|
||||
- {fileID: 1131199853383832992}
|
||||
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: d406f8f3cbe268f4e9d0234d45cca60c, type: 3}
|
||||
m_Tag:
|
||||
m_SpeedParameter:
|
||||
m_MirrorParameter:
|
||||
m_CycleOffsetParameter:
|
||||
m_TimeParameter:
|
||||
--- !u!1101 &-4911913766117122026
|
||||
AnimatorStateTransition:
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name:
|
||||
m_Conditions:
|
||||
- m_ConditionMode: 2
|
||||
m_ConditionEvent: _died
|
||||
m_EventTreshold: 0
|
||||
m_DstStateMachine: {fileID: 0}
|
||||
m_DstState: {fileID: 0}
|
||||
m_Solo: 0
|
||||
m_Mute: 0
|
||||
m_IsExit: 1
|
||||
serializedVersion: 3
|
||||
m_TransitionDuration: 0.25
|
||||
m_TransitionOffset: 0
|
||||
m_ExitTime: 0.765625
|
||||
m_HasExitTime: 1
|
||||
m_HasFixedDuration: 1
|
||||
m_InterruptionSource: 0
|
||||
m_OrderedInterruption: 1
|
||||
m_CanTransitionToSelf: 1
|
||||
--- !u!1101 &-4865886577319040672
|
||||
AnimatorStateTransition:
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Run to Jump
|
||||
m_Conditions:
|
||||
- m_ConditionMode: 1
|
||||
m_ConditionEvent: _jump
|
||||
m_EventTreshold: 0
|
||||
m_DstStateMachine: {fileID: 0}
|
||||
m_DstState: {fileID: -5914497066343941395}
|
||||
m_Solo: 0
|
||||
m_Mute: 0
|
||||
m_IsExit: 0
|
||||
serializedVersion: 3
|
||||
m_TransitionDuration: 0.25
|
||||
m_TransitionOffset: 0
|
||||
m_ExitTime: 0.75
|
||||
m_HasExitTime: 0
|
||||
m_HasFixedDuration: 1
|
||||
m_InterruptionSource: 0
|
||||
m_OrderedInterruption: 1
|
||||
m_CanTransitionToSelf: 1
|
||||
--- !u!1102 &-4600760231423422918
|
||||
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: -632880110147916710}
|
||||
- {fileID: -6673604382440492192}
|
||||
- {fileID: -70235823626180740}
|
||||
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: 107649059ea401b4e9c5c20f21e99a55, type: 3}
|
||||
m_Tag:
|
||||
m_SpeedParameter:
|
||||
m_MirrorParameter:
|
||||
m_CycleOffsetParameter:
|
||||
m_TimeParameter:
|
||||
--- !u!1102 &-4187437994059944167
|
||||
AnimatorState:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Fire
|
||||
m_Speed: 10
|
||||
m_CycleOffset: 0
|
||||
m_Transitions:
|
||||
- {fileID: -146642472328627549}
|
||||
- {fileID: -8614502741554326989}
|
||||
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: 1d4365e1541bb6949a273318862b72d3, type: 3}
|
||||
m_Tag:
|
||||
m_SpeedParameter:
|
||||
m_MirrorParameter:
|
||||
m_CycleOffsetParameter:
|
||||
m_TimeParameter:
|
||||
--- !u!1101 &-4114131529631250501
|
||||
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: _died
|
||||
m_EventTreshold: 0
|
||||
m_DstStateMachine: {fileID: 0}
|
||||
m_DstState: {fileID: -5023192667791512651}
|
||||
m_Solo: 0
|
||||
m_Mute: 0
|
||||
m_IsExit: 0
|
||||
serializedVersion: 3
|
||||
m_TransitionDuration: 0.7343743
|
||||
m_TransitionOffset: 0.08256394
|
||||
m_ExitTime: 0.28710982
|
||||
m_HasExitTime: 0
|
||||
m_HasFixedDuration: 1
|
||||
m_InterruptionSource: 0
|
||||
m_OrderedInterruption: 1
|
||||
m_CanTransitionToSelf: 1
|
||||
--- !u!1101 &-3812287898245291883
|
||||
AnimatorStateTransition:
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Jump to Run
|
||||
m_Conditions: []
|
||||
m_DstStateMachine: {fileID: 0}
|
||||
m_DstState: {fileID: 8354844821256608690}
|
||||
m_Solo: 0
|
||||
m_Mute: 0
|
||||
m_IsExit: 0
|
||||
serializedVersion: 3
|
||||
m_TransitionDuration: 0.20300466
|
||||
m_TransitionOffset: 0
|
||||
m_ExitTime: 0.7916667
|
||||
m_HasExitTime: 1
|
||||
m_HasFixedDuration: 1
|
||||
m_InterruptionSource: 0
|
||||
m_OrderedInterruption: 1
|
||||
m_CanTransitionToSelf: 1
|
||||
--- !u!1101 &-3071590976036615157
|
||||
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: _died
|
||||
m_EventTreshold: 0
|
||||
m_DstStateMachine: {fileID: 0}
|
||||
m_DstState: {fileID: 381506674367370628}
|
||||
m_Solo: 0
|
||||
m_Mute: 0
|
||||
m_IsExit: 0
|
||||
serializedVersion: 3
|
||||
m_TransitionDuration: 0.25
|
||||
m_TransitionOffset: 0.542241
|
||||
m_ExitTime: 0.75
|
||||
m_HasExitTime: 1
|
||||
m_HasFixedDuration: 1
|
||||
m_InterruptionSource: 0
|
||||
m_OrderedInterruption: 1
|
||||
m_CanTransitionToSelf: 1
|
||||
--- !u!1107 &-2302487397917704150
|
||||
AnimatorStateMachine:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Lower
|
||||
m_ChildStates:
|
||||
- serializedVersion: 1
|
||||
m_State: {fileID: 8354844821256608690}
|
||||
m_Position: {x: 460, y: 60, z: 0}
|
||||
- serializedVersion: 1
|
||||
m_State: {fileID: -5914497066343941395}
|
||||
m_Position: {x: 580, y: -120, z: 0}
|
||||
- serializedVersion: 1
|
||||
m_State: {fileID: -1946935121236979824}
|
||||
m_Position: {x: 490, y: 230, z: 0}
|
||||
- serializedVersion: 1
|
||||
m_State: {fileID: 381506674367370628}
|
||||
m_Position: {x: 980, y: 60, z: 0}
|
||||
m_ChildStateMachines: []
|
||||
m_AnyStateTransitions: []
|
||||
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: 1130, y: 240, z: 0}
|
||||
m_ParentStateMachinePosition: {x: 800, y: 20, z: 0}
|
||||
m_DefaultState: {fileID: 8354844821256608690}
|
||||
--- !u!1102 &-1946935121236979824
|
||||
AnimatorState:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Crouch
|
||||
m_Speed: 1
|
||||
m_CycleOffset: 0
|
||||
m_Transitions:
|
||||
- {fileID: 5680347307725438578}
|
||||
- {fileID: -3071590976036615157}
|
||||
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: 3ad7c5979f6586d4a9532a55492a0ebe, type: 3}
|
||||
m_Tag:
|
||||
m_SpeedParameter:
|
||||
m_MirrorParameter: _jump
|
||||
m_CycleOffsetParameter:
|
||||
m_TimeParameter:
|
||||
--- !u!206 &-1862914767576164720
|
||||
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: 107649059ea401b4e9c5c20f21e99a55, type: 3}
|
||||
m_Threshold: 0
|
||||
m_Position: {x: 0, y: 0}
|
||||
m_TimeScale: 0.5
|
||||
m_CycleOffset: 0
|
||||
m_DirectBlendParameter: horizontal
|
||||
m_Mirror: 0
|
||||
- serializedVersion: 2
|
||||
m_Motion: {fileID: 7400000, guid: 043a0882d93547c4da0104443de76efb, type: 3}
|
||||
m_Threshold: 1
|
||||
m_Position: {x: 1, y: 0}
|
||||
m_TimeScale: 1
|
||||
m_CycleOffset: 0
|
||||
m_DirectBlendParameter: horizontal
|
||||
m_Mirror: 0
|
||||
m_BlendParameter: _vertical
|
||||
m_BlendParameterY: _horizontal
|
||||
m_MinThreshold: 0
|
||||
m_MaxThreshold: 1
|
||||
m_UseAutomaticThresholds: 1
|
||||
m_NormalizedBlendValues: 0
|
||||
m_BlendType: 3
|
||||
--- !u!1101 &-632880110147916710
|
||||
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: _jump
|
||||
m_EventTreshold: 0
|
||||
m_DstStateMachine: {fileID: 0}
|
||||
m_DstState: {fileID: 7739110899394721029}
|
||||
m_Solo: 0
|
||||
m_Mute: 0
|
||||
m_IsExit: 0
|
||||
serializedVersion: 3
|
||||
m_TransitionDuration: 0.25
|
||||
m_TransitionOffset: 0
|
||||
m_ExitTime: 0.8125
|
||||
m_HasExitTime: 1
|
||||
m_HasFixedDuration: 1
|
||||
m_InterruptionSource: 0
|
||||
m_OrderedInterruption: 1
|
||||
m_CanTransitionToSelf: 1
|
||||
--- !u!1101 &-146642472328627549
|
||||
AnimatorStateTransition:
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name:
|
||||
m_Conditions:
|
||||
- m_ConditionMode: 2
|
||||
m_ConditionEvent: _fired
|
||||
m_EventTreshold: 0
|
||||
m_DstStateMachine: {fileID: 0}
|
||||
m_DstState: {fileID: -4600760231423422918}
|
||||
m_Solo: 0
|
||||
m_Mute: 0
|
||||
m_IsExit: 0
|
||||
serializedVersion: 3
|
||||
m_TransitionDuration: 0.25
|
||||
m_TransitionOffset: 0
|
||||
m_ExitTime: 0.8125
|
||||
m_HasExitTime: 1
|
||||
m_HasFixedDuration: 1
|
||||
m_InterruptionSource: 0
|
||||
m_OrderedInterruption: 1
|
||||
m_CanTransitionToSelf: 1
|
||||
--- !u!1101 &-70235823626180740
|
||||
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: _died
|
||||
m_EventTreshold: 0
|
||||
m_DstStateMachine: {fileID: 0}
|
||||
m_DstState: {fileID: -5023192667791512651}
|
||||
m_Solo: 0
|
||||
m_Mute: 0
|
||||
m_IsExit: 0
|
||||
serializedVersion: 3
|
||||
m_TransitionDuration: 0.982062
|
||||
m_TransitionOffset: 0.000000027939697
|
||||
m_ExitTime: 0.26345384
|
||||
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: CharacterAnimator
|
||||
serializedVersion: 5
|
||||
m_AnimatorParameters:
|
||||
- m_Name: _horizontal
|
||||
m_Type: 1
|
||||
m_DefaultFloat: 0
|
||||
m_DefaultInt: 0
|
||||
m_DefaultBool: 0
|
||||
m_Controller: {fileID: 9100000}
|
||||
- m_Name: _vertical
|
||||
m_Type: 1
|
||||
m_DefaultFloat: 1
|
||||
m_DefaultInt: 0
|
||||
m_DefaultBool: 0
|
||||
m_Controller: {fileID: 9100000}
|
||||
- m_Name: _jump
|
||||
m_Type: 4
|
||||
m_DefaultFloat: 0
|
||||
m_DefaultInt: 0
|
||||
m_DefaultBool: 0
|
||||
m_Controller: {fileID: 9100000}
|
||||
- m_Name: _crouch
|
||||
m_Type: 4
|
||||
m_DefaultFloat: 0
|
||||
m_DefaultInt: 0
|
||||
m_DefaultBool: 0
|
||||
m_Controller: {fileID: 9100000}
|
||||
- m_Name: _died
|
||||
m_Type: 4
|
||||
m_DefaultFloat: 0
|
||||
m_DefaultInt: 0
|
||||
m_DefaultBool: 0
|
||||
m_Controller: {fileID: 9100000}
|
||||
- m_Name: _fired
|
||||
m_Type: 4
|
||||
m_DefaultFloat: 0
|
||||
m_DefaultInt: 0
|
||||
m_DefaultBool: 0
|
||||
m_Controller: {fileID: 9100000}
|
||||
m_AnimatorLayers:
|
||||
- serializedVersion: 5
|
||||
m_Name: Lower
|
||||
m_StateMachine: {fileID: -2302487397917704150}
|
||||
m_Mask: {fileID: 31900000, guid: 1122aed799ca7574a8f0d2efa30e9d99, type: 2}
|
||||
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: Upper
|
||||
m_StateMachine: {fileID: -8265500127550764659}
|
||||
m_Mask: {fileID: 31900000, guid: 368b178fc56a14549b588ee80c7cbf81, 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}
|
||||
--- !u!1102 &381506674367370628
|
||||
AnimatorState:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Die
|
||||
m_Speed: 1
|
||||
m_CycleOffset: 0
|
||||
m_Transitions:
|
||||
- {fileID: -4911913766117122026}
|
||||
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: d406f8f3cbe268f4e9d0234d45cca60c, type: 3}
|
||||
m_Tag:
|
||||
m_SpeedParameter:
|
||||
m_MirrorParameter:
|
||||
m_CycleOffsetParameter:
|
||||
m_TimeParameter:
|
||||
--- !u!1101 &1131199853383832992
|
||||
AnimatorStateTransition:
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name:
|
||||
m_Conditions:
|
||||
- m_ConditionMode: 2
|
||||
m_ConditionEvent: _died
|
||||
m_EventTreshold: 0
|
||||
m_DstStateMachine: {fileID: 0}
|
||||
m_DstState: {fileID: 0}
|
||||
m_Solo: 0
|
||||
m_Mute: 0
|
||||
m_IsExit: 1
|
||||
serializedVersion: 3
|
||||
m_TransitionDuration: 0.25
|
||||
m_TransitionOffset: 0
|
||||
m_ExitTime: 0.765625
|
||||
m_HasExitTime: 1
|
||||
m_HasFixedDuration: 1
|
||||
m_InterruptionSource: 0
|
||||
m_OrderedInterruption: 1
|
||||
m_CanTransitionToSelf: 1
|
||||
--- !u!1101 &1426403871767708545
|
||||
AnimatorStateTransition:
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name:
|
||||
m_Conditions:
|
||||
- m_ConditionMode: 2
|
||||
m_ConditionEvent: _died
|
||||
m_EventTreshold: 0
|
||||
m_DstStateMachine: {fileID: 0}
|
||||
m_DstState: {fileID: 0}
|
||||
m_Solo: 0
|
||||
m_Mute: 0
|
||||
m_IsExit: 1
|
||||
serializedVersion: 3
|
||||
m_TransitionDuration: 0.25
|
||||
m_TransitionOffset: 0
|
||||
m_ExitTime: 0.765625
|
||||
m_HasExitTime: 1
|
||||
m_HasFixedDuration: 1
|
||||
m_InterruptionSource: 0
|
||||
m_OrderedInterruption: 1
|
||||
m_CanTransitionToSelf: 1
|
||||
--- !u!1101 &1766918516916494365
|
||||
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: _crouch
|
||||
m_EventTreshold: 0
|
||||
m_DstStateMachine: {fileID: 0}
|
||||
m_DstState: {fileID: -1946935121236979824}
|
||||
m_Solo: 0
|
||||
m_Mute: 0
|
||||
m_IsExit: 0
|
||||
serializedVersion: 3
|
||||
m_TransitionDuration: 0.25
|
||||
m_TransitionOffset: 0
|
||||
m_ExitTime: 0.75
|
||||
m_HasExitTime: 0
|
||||
m_HasFixedDuration: 1
|
||||
m_InterruptionSource: 0
|
||||
m_OrderedInterruption: 1
|
||||
m_CanTransitionToSelf: 1
|
||||
--- !u!1101 &2942481661802285141
|
||||
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: _died
|
||||
m_EventTreshold: 0
|
||||
m_DstStateMachine: {fileID: 0}
|
||||
m_DstState: {fileID: 381506674367370628}
|
||||
m_Solo: 0
|
||||
m_Mute: 0
|
||||
m_IsExit: 0
|
||||
serializedVersion: 3
|
||||
m_TransitionDuration: 0.45466095
|
||||
m_TransitionOffset: 0
|
||||
m_ExitTime: 0.5480226
|
||||
m_HasExitTime: 1
|
||||
m_HasFixedDuration: 1
|
||||
m_InterruptionSource: 0
|
||||
m_OrderedInterruption: 1
|
||||
m_CanTransitionToSelf: 1
|
||||
--- !u!1101 &4669644873837644826
|
||||
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: _died
|
||||
m_EventTreshold: 0
|
||||
m_DstStateMachine: {fileID: 0}
|
||||
m_DstState: {fileID: 381506674367370628}
|
||||
m_Solo: 0
|
||||
m_Mute: 0
|
||||
m_IsExit: 0
|
||||
serializedVersion: 3
|
||||
m_TransitionDuration: 1.0268358
|
||||
m_TransitionOffset: 0.026483208
|
||||
m_ExitTime: 0.22033934
|
||||
m_HasExitTime: 0
|
||||
m_HasFixedDuration: 1
|
||||
m_InterruptionSource: 0
|
||||
m_OrderedInterruption: 1
|
||||
m_CanTransitionToSelf: 1
|
||||
--- !u!1101 &5168308916736617153
|
||||
AnimatorStateTransition:
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Jump to Run
|
||||
m_Conditions: []
|
||||
m_DstStateMachine: {fileID: 0}
|
||||
m_DstState: {fileID: 8354844821256608690}
|
||||
m_Solo: 0
|
||||
m_Mute: 0
|
||||
m_IsExit: 0
|
||||
serializedVersion: 3
|
||||
m_TransitionDuration: 0.20300466
|
||||
m_TransitionOffset: 0
|
||||
m_ExitTime: 0.7916667
|
||||
m_HasExitTime: 1
|
||||
m_HasFixedDuration: 1
|
||||
m_InterruptionSource: 0
|
||||
m_OrderedInterruption: 1
|
||||
m_CanTransitionToSelf: 1
|
||||
--- !u!1101 &5680347307725438578
|
||||
AnimatorStateTransition:
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name:
|
||||
m_Conditions:
|
||||
- m_ConditionMode: 2
|
||||
m_ConditionEvent: _crouch
|
||||
m_EventTreshold: 0
|
||||
m_DstStateMachine: {fileID: 0}
|
||||
m_DstState: {fileID: 8354844821256608690}
|
||||
m_Solo: 1
|
||||
m_Mute: 0
|
||||
m_IsExit: 0
|
||||
serializedVersion: 3
|
||||
m_TransitionDuration: 0.09322041
|
||||
m_TransitionOffset: 0
|
||||
m_ExitTime: 0.75
|
||||
m_HasExitTime: 0
|
||||
m_HasFixedDuration: 1
|
||||
m_InterruptionSource: 0
|
||||
m_OrderedInterruption: 1
|
||||
m_CanTransitionToSelf: 1
|
||||
--- !u!1101 &7161422939700495704
|
||||
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: _died
|
||||
m_EventTreshold: 0
|
||||
m_DstStateMachine: {fileID: 0}
|
||||
m_DstState: {fileID: 381506674367370628}
|
||||
m_Solo: 0
|
||||
m_Mute: 0
|
||||
m_IsExit: 0
|
||||
serializedVersion: 3
|
||||
m_TransitionDuration: 0.45466095
|
||||
m_TransitionOffset: 0
|
||||
m_ExitTime: 0.5480226
|
||||
m_HasExitTime: 1
|
||||
m_HasFixedDuration: 1
|
||||
m_InterruptionSource: 0
|
||||
m_OrderedInterruption: 1
|
||||
m_CanTransitionToSelf: 1
|
||||
--- !u!1102 &7739110899394721029
|
||||
AnimatorState:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Jump
|
||||
m_Speed: 1
|
||||
m_CycleOffset: 0
|
||||
m_Transitions:
|
||||
- {fileID: -5341886129914063569}
|
||||
- {fileID: -4114131529631250501}
|
||||
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: c09541f4236345c4fa4e4745793a59f3, type: 3}
|
||||
m_Tag:
|
||||
m_SpeedParameter:
|
||||
m_MirrorParameter:
|
||||
m_CycleOffsetParameter:
|
||||
m_TimeParameter:
|
||||
--- !u!1102 &8354844821256608690
|
||||
AnimatorState:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Locomotion
|
||||
m_Speed: 1
|
||||
m_CycleOffset: 0
|
||||
m_Transitions:
|
||||
- {fileID: -4865886577319040672}
|
||||
- {fileID: 1766918516916494365}
|
||||
- {fileID: 4669644873837644826}
|
||||
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: -1862914767576164720}
|
||||
m_Tag:
|
||||
m_SpeedParameter:
|
||||
m_MirrorParameter:
|
||||
m_CycleOffsetParameter:
|
||||
m_TimeParameter:
|
||||
--- !u!1101 &9141976730198879995
|
||||
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: _died
|
||||
m_EventTreshold: 0
|
||||
m_DstStateMachine: {fileID: 0}
|
||||
m_DstState: {fileID: 381506674367370628}
|
||||
m_Solo: 0
|
||||
m_Mute: 0
|
||||
m_IsExit: 0
|
||||
serializedVersion: 3
|
||||
m_TransitionDuration: 0.45466095
|
||||
m_TransitionOffset: 0
|
||||
m_ExitTime: 0.5480226
|
||||
m_HasExitTime: 1
|
||||
m_HasFixedDuration: 1
|
||||
m_InterruptionSource: 0
|
||||
m_OrderedInterruption: 1
|
||||
m_CanTransitionToSelf: 1
|
8
Assets/Scripts/Animators/Leonid Animator/CharacterAnimator.controller.meta
generated
Normal file
8
Assets/Scripts/Animators/Leonid Animator/CharacterAnimator.controller.meta
generated
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3ebf60422b6cb1c498ee4cf238072b43
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 9100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
105
Assets/Scripts/Animators/Leonid Animator/CharacterLocomotion.cs
Normal file
105
Assets/Scripts/Animators/Leonid Animator/CharacterLocomotion.cs
Normal file
@ -0,0 +1,105 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Animators.Leonid_Animator
|
||||
{
|
||||
[RequireComponent(
|
||||
typeof(Rigidbody),
|
||||
typeof(InputHandler),
|
||||
typeof(AnimatorHandler))]
|
||||
public class CharacterLocomotion : MonoBehaviour
|
||||
{
|
||||
private Transform _cameraObject;
|
||||
private InputHandler _inputHandler;
|
||||
private Vector3 _moveDirection;
|
||||
|
||||
[HideInInspector] public Transform myTransform;
|
||||
[HideInInspector] public AnimatorHandler myAnimatorHandler;
|
||||
|
||||
public Rigidbody myRigidbody;
|
||||
[SerializeField] public float jumpForce;
|
||||
public GameObject normalCamera;
|
||||
|
||||
[Header("Stats")]
|
||||
[SerializeField] private float movementSpeed = 5;
|
||||
[SerializeField] private float rotationSpeed = 10;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
myRigidbody = GetComponent<Rigidbody>();
|
||||
_inputHandler = GetComponent<InputHandler>();
|
||||
myAnimatorHandler = GetComponent<AnimatorHandler>();
|
||||
|
||||
_cameraObject = Camera.main.transform;
|
||||
myTransform = transform;
|
||||
myAnimatorHandler.Initialize();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
var deltaTime = Time.deltaTime;
|
||||
_inputHandler.TickInput(deltaTime);
|
||||
_moveDirection = _cameraObject.forward * _inputHandler.vertical
|
||||
+ _cameraObject.right * _inputHandler.horizontal;
|
||||
_moveDirection.Normalize();
|
||||
_moveDirection *= movementSpeed;
|
||||
_moveDirection.y = 0;
|
||||
|
||||
var projectedVelocity = Vector3.ProjectOnPlane(_moveDirection, _normalVector);
|
||||
myRigidbody.velocity = projectedVelocity;
|
||||
|
||||
if (myAnimatorHandler.canRotate)
|
||||
{
|
||||
HandleRotation(deltaTime);
|
||||
}
|
||||
|
||||
myAnimatorHandler.UpdateAnimatorValues(
|
||||
_inputHandler.moveAmount,
|
||||
0,
|
||||
_inputHandler.jumpPressed,
|
||||
_inputHandler.crouchPressed,
|
||||
_inputHandler.firePressed);
|
||||
|
||||
var velocity = myRigidbody.velocity;
|
||||
myRigidbody.AddForce(_inputHandler.jumpPressed ?
|
||||
new Vector3(0, jumpForce, 0)
|
||||
: new Vector3(velocity.x*100, -50, velocity.z * 100));
|
||||
}
|
||||
|
||||
private void LateUpdate()
|
||||
{
|
||||
_inputHandler.jumpPressed = false;
|
||||
_inputHandler.crouchPressed = false;
|
||||
}
|
||||
|
||||
#region Movement
|
||||
|
||||
private Vector3 _normalVector;
|
||||
private Vector3 _targetPosition;
|
||||
|
||||
private void HandleRotation(float delta)
|
||||
{
|
||||
if (Mathf.Abs(_inputHandler.horizontal) + Mathf.Abs(_inputHandler.vertical) < 0.1)
|
||||
{
|
||||
print("stop");
|
||||
return;
|
||||
}
|
||||
|
||||
print("begin");
|
||||
var moveAmount = _inputHandler.moveAmount;
|
||||
var targetDir = _cameraObject.forward * _inputHandler.vertical
|
||||
+ _cameraObject.right * _inputHandler.horizontal;
|
||||
targetDir.Normalize();
|
||||
targetDir.y = 0;
|
||||
if (targetDir == Vector3.zero)
|
||||
targetDir = myTransform.forward;
|
||||
|
||||
var rotSpeed = rotationSpeed;
|
||||
|
||||
var rotation = Quaternion.LookRotation(targetDir);
|
||||
var targetRotation = Quaternion.Slerp(myTransform.rotation, rotation, rotationSpeed * delta);
|
||||
myTransform.rotation = targetRotation;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
3
Assets/Scripts/Animators/Leonid Animator/CharacterLocomotion.cs.meta
generated
Normal file
3
Assets/Scripts/Animators/Leonid Animator/CharacterLocomotion.cs.meta
generated
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: aeafb7b8074141969e8779cd3d4a9d08
|
||||
timeCreated: 1652026088
|
77
Assets/Scripts/Animators/Leonid Animator/InputHandler.cs
Normal file
77
Assets/Scripts/Animators/Leonid Animator/InputHandler.cs
Normal file
@ -0,0 +1,77 @@
|
||||
using CameraScripts;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Animators.Leonid_Animator
|
||||
{
|
||||
public class InputHandler : MonoBehaviour
|
||||
{
|
||||
public float horizontal;
|
||||
public float vertical;
|
||||
public float moveAmount;
|
||||
public float mouseX;
|
||||
public float mouseY;
|
||||
|
||||
public bool crouchPressed;
|
||||
public bool jumpPressed;
|
||||
public bool firePressed;
|
||||
|
||||
private ThirdPersonViewInput _inputActions;
|
||||
private Vector2 _movementInput;
|
||||
private Vector2 _cameraInput;
|
||||
|
||||
private CameraHandler _cameraHandler;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_cameraHandler = CameraHandler.Singleton;
|
||||
if (_cameraHandler == null)
|
||||
Debug.LogError("Camera Handler not found");
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
_cameraHandler.TargetPosition(Time.deltaTime);
|
||||
_cameraHandler.HandleCameraRotation(Time.deltaTime, mouseX, mouseY);
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
if (_inputActions is null)
|
||||
{
|
||||
_inputActions = new ThirdPersonViewInput();
|
||||
_inputActions.PlayerMovement.Movement.performed +=
|
||||
context => _movementInput = context.ReadValue<Vector2>();
|
||||
_inputActions.PlayerMovement.Camera.performed +=
|
||||
context => _cameraInput = context.ReadValue<Vector2>();
|
||||
_inputActions.PlayerActions.Crouch.performed +=
|
||||
context => crouchPressed = true;
|
||||
_inputActions.PlayerActions.Jump.performed +=
|
||||
context => jumpPressed = true;
|
||||
_inputActions.PlayerActions.Fire.performed +=
|
||||
context => firePressed = true;
|
||||
_inputActions.PlayerActions.Fire.canceled +=
|
||||
context => firePressed = false;
|
||||
}
|
||||
_inputActions.Enable();
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
_inputActions.Disable();
|
||||
}
|
||||
|
||||
public void TickInput(float delta)
|
||||
{
|
||||
MoveInput(delta);
|
||||
}
|
||||
|
||||
private void MoveInput(float delta)
|
||||
{
|
||||
horizontal = _movementInput.x;
|
||||
vertical = _movementInput.y;
|
||||
moveAmount = Mathf.Clamp01(Mathf.Abs(horizontal) + Mathf.Abs(vertical));
|
||||
mouseX = _cameraInput.x;
|
||||
mouseY = _cameraInput.y;
|
||||
}
|
||||
}
|
||||
}
|
3
Assets/Scripts/Animators/Leonid Animator/InputHandler.cs.meta
generated
Normal file
3
Assets/Scripts/Animators/Leonid Animator/InputHandler.cs.meta
generated
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 77c38ddfaba349c590d4a6583f7efac4
|
||||
timeCreated: 1652025145
|
139
Assets/Scripts/Animators/Leonid Animator/LowerBody.mask
Normal file
139
Assets/Scripts/Animators/Leonid Animator/LowerBody.mask
Normal file
@ -0,0 +1,139 @@
|
||||
%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: LowerBody
|
||||
m_Mask: 01000000010000000100000001000000010000000100000001000000010000000100000001000000010000000100000001000000
|
||||
m_Elements:
|
||||
- m_Path:
|
||||
m_Weight: 1
|
||||
- m_Path: Arm1
|
||||
m_Weight: 1
|
||||
- m_Path: AssaultRifle
|
||||
m_Weight: 1
|
||||
- m_Path: Backpack1
|
||||
m_Weight: 1
|
||||
- m_Path: Body1
|
||||
m_Weight: 1
|
||||
- m_Path: head1
|
||||
m_Weight: 1
|
||||
- m_Path: Hips
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/ArmPosition_Left
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/ArmPosition_Right
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/ArmPosition_Right/magazine_Right
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/ArmPosition_Right/Trigger_Right
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/Spine
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/Spine/Chest
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/Spine/Chest/BackPack
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/Spine/Chest/BackPack/ArmPlacement_Left
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/Spine/Chest/BackPack/ArmPlacement_Right
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/Spine/Chest/BackPack/ArmPlacement_Upper
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/Spine/Chest/Neck
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/Spine/Chest/Neck/Head
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/Spine/Chest/Neck/Head/Headgear_Left
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/Spine/Chest/Neck/Head/Headgear_Right
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/Spine/Chest/Shoulder_Left
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/Spine/Chest/Shoulder_Left/ShoulderPadCTRL_Left
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/Spine/Chest/Shoulder_Left/ShoulderPadCTRL_Left/ShoulderPadBlade_Left
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/Spine/Chest/Shoulder_Left/ShoulderPadCTRL_Left/ShoulderPadBody_Left
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/Spine/Chest/Shoulder_Left/UpperArm_Left
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/Spine/Chest/Shoulder_Left/UpperArm_Left/LowerArm_Left
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/Spine/Chest/Shoulder_Left/UpperArm_Left/LowerArm_Left/Hand_Left
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/Spine/Chest/Shoulder_Left/UpperArm_Left/LowerArm_Left/Hand_Left/Index_Proximal_Left
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/Spine/Chest/Shoulder_Left/UpperArm_Left/LowerArm_Left/Hand_Left/Index_Proximal_Left/Index_Intermediate_Left
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/Spine/Chest/Shoulder_Left/UpperArm_Left/LowerArm_Left/Hand_Left/Index_Proximal_Left/Index_Intermediate_Left/Index_Distal_Left
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/Spine/Chest/Shoulder_Left/UpperArm_Left/LowerArm_Left/Hand_Left/RestOfFingers_Proximal_Left
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/Spine/Chest/Shoulder_Left/UpperArm_Left/LowerArm_Left/Hand_Left/RestOfFingers_Proximal_Left/RestOfFingers_Intermediate_Left
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/Spine/Chest/Shoulder_Left/UpperArm_Left/LowerArm_Left/Hand_Left/RestOfFingers_Proximal_Left/RestOfFingers_Intermediate_Left/RestOfFingers_Distal_Left
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/Spine/Chest/Shoulder_Left/UpperArm_Left/LowerArm_Left/Hand_Left/Thumb_Proximal_Left
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/Spine/Chest/Shoulder_Left/UpperArm_Left/LowerArm_Left/Hand_Left/Thumb_Proximal_Left/Thumb_Intermediate_Left
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/Spine/Chest/Shoulder_Left/UpperArm_Left/LowerArm_Left/Hand_Left/Thumb_Proximal_Left/Thumb_Intermediate_Left/Thumb_Distal_Left
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/Spine/Chest/Shoulder_Right
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/Spine/Chest/Shoulder_Right/ShoulderPadCTRL_Right
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/Spine/Chest/Shoulder_Right/ShoulderPadCTRL_Right/ShoulderPadBlade_Right
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/Spine/Chest/Shoulder_Right/ShoulderPadCTRL_Right/ShoulderPadBody_Right
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/Spine/Chest/Shoulder_Right/UpperArm_Right
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/Spine/Chest/Shoulder_Right/UpperArm_Right/LowerArm_Right
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/Spine/Chest/Shoulder_Right/UpperArm_Right/LowerArm_Right/Hand_Right
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/Spine/Chest/Shoulder_Right/UpperArm_Right/LowerArm_Right/Hand_Right/Index_Proximal_Right
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/Spine/Chest/Shoulder_Right/UpperArm_Right/LowerArm_Right/Hand_Right/Index_Proximal_Right/Index_Intermediate_Right
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/Spine/Chest/Shoulder_Right/UpperArm_Right/LowerArm_Right/Hand_Right/Index_Proximal_Right/Index_Intermediate_Right/Index_Distal_Right
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/Spine/Chest/Shoulder_Right/UpperArm_Right/LowerArm_Right/Hand_Right/RestOfFingers_Proximal_Right
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/Spine/Chest/Shoulder_Right/UpperArm_Right/LowerArm_Right/Hand_Right/RestOfFingers_Proximal_Right/RestOfFingers_Intermediate_Right
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/Spine/Chest/Shoulder_Right/UpperArm_Right/LowerArm_Right/Hand_Right/RestOfFingers_Proximal_Right/RestOfFingers_Intermediate_Right/RestOfFingers_Distal_Right
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/Spine/Chest/Shoulder_Right/UpperArm_Right/LowerArm_Right/Hand_Right/Thumb_Proximal_Right
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/Spine/Chest/Shoulder_Right/UpperArm_Right/LowerArm_Right/Hand_Right/Thumb_Proximal_Right/Thumb_Intermediate_Right
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/Spine/Chest/Shoulder_Right/UpperArm_Right/LowerArm_Right/Hand_Right/Thumb_Proximal_Right/Thumb_Intermediate_Right/Thumb_Distal_Right
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/UpperLeg_Left
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/UpperLeg_Left/LowerLeg_Left
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/UpperLeg_Left/LowerLeg_Left/Foot_Left
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/UpperLeg_Left/LowerLeg_Left/Foot_Left/Toe_Left
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/UpperLeg_Left/LowerLeg_Left/Foot_Left/Toe_Left/Toetip_Left
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/UpperLeg_Right
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/UpperLeg_Right/LowerLeg_Right
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/UpperLeg_Right/LowerLeg_Right/Foot_Right
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/UpperLeg_Right/LowerLeg_Right/Foot_Right/Toe_Right
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/UpperLeg_Right/LowerLeg_Right/Foot_Right/Toe_Right/Toetip_Right
|
||||
m_Weight: 1
|
||||
- m_Path: Leg1
|
||||
m_Weight: 1
|
8
Assets/Scripts/Animators/Leonid Animator/LowerBody.mask.meta
generated
Normal file
8
Assets/Scripts/Animators/Leonid Animator/LowerBody.mask.meta
generated
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1122aed799ca7574a8f0d2efa30e9d99
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 31900000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
139
Assets/Scripts/Animators/Leonid Animator/UpperBody.mask
Normal file
139
Assets/Scripts/Animators/Leonid Animator/UpperBody.mask
Normal file
@ -0,0 +1,139 @@
|
||||
%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: UpperBody
|
||||
m_Mask: 00000000010000000100000000000000000000000100000001000000010000000100000000000000000000000000000000000000
|
||||
m_Elements:
|
||||
- m_Path:
|
||||
m_Weight: 1
|
||||
- m_Path: Arm1
|
||||
m_Weight: 1
|
||||
- m_Path: AssaultRifle
|
||||
m_Weight: 1
|
||||
- m_Path: Backpack1
|
||||
m_Weight: 1
|
||||
- m_Path: Body1
|
||||
m_Weight: 1
|
||||
- m_Path: head1
|
||||
m_Weight: 1
|
||||
- m_Path: Hips
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/ArmPosition_Left
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/ArmPosition_Right
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/ArmPosition_Right/magazine_Right
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/ArmPosition_Right/Trigger_Right
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/Spine
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/Spine/Chest
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/Spine/Chest/BackPack
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/Spine/Chest/BackPack/ArmPlacement_Left
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/Spine/Chest/BackPack/ArmPlacement_Right
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/Spine/Chest/BackPack/ArmPlacement_Upper
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/Spine/Chest/Neck
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/Spine/Chest/Neck/Head
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/Spine/Chest/Neck/Head/Headgear_Left
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/Spine/Chest/Neck/Head/Headgear_Right
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/Spine/Chest/Shoulder_Left
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/Spine/Chest/Shoulder_Left/ShoulderPadCTRL_Left
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/Spine/Chest/Shoulder_Left/ShoulderPadCTRL_Left/ShoulderPadBlade_Left
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/Spine/Chest/Shoulder_Left/ShoulderPadCTRL_Left/ShoulderPadBody_Left
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/Spine/Chest/Shoulder_Left/UpperArm_Left
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/Spine/Chest/Shoulder_Left/UpperArm_Left/LowerArm_Left
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/Spine/Chest/Shoulder_Left/UpperArm_Left/LowerArm_Left/Hand_Left
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/Spine/Chest/Shoulder_Left/UpperArm_Left/LowerArm_Left/Hand_Left/Index_Proximal_Left
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/Spine/Chest/Shoulder_Left/UpperArm_Left/LowerArm_Left/Hand_Left/Index_Proximal_Left/Index_Intermediate_Left
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/Spine/Chest/Shoulder_Left/UpperArm_Left/LowerArm_Left/Hand_Left/Index_Proximal_Left/Index_Intermediate_Left/Index_Distal_Left
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/Spine/Chest/Shoulder_Left/UpperArm_Left/LowerArm_Left/Hand_Left/RestOfFingers_Proximal_Left
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/Spine/Chest/Shoulder_Left/UpperArm_Left/LowerArm_Left/Hand_Left/RestOfFingers_Proximal_Left/RestOfFingers_Intermediate_Left
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/Spine/Chest/Shoulder_Left/UpperArm_Left/LowerArm_Left/Hand_Left/RestOfFingers_Proximal_Left/RestOfFingers_Intermediate_Left/RestOfFingers_Distal_Left
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/Spine/Chest/Shoulder_Left/UpperArm_Left/LowerArm_Left/Hand_Left/Thumb_Proximal_Left
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/Spine/Chest/Shoulder_Left/UpperArm_Left/LowerArm_Left/Hand_Left/Thumb_Proximal_Left/Thumb_Intermediate_Left
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/Spine/Chest/Shoulder_Left/UpperArm_Left/LowerArm_Left/Hand_Left/Thumb_Proximal_Left/Thumb_Intermediate_Left/Thumb_Distal_Left
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/Spine/Chest/Shoulder_Right
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/Spine/Chest/Shoulder_Right/ShoulderPadCTRL_Right
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/Spine/Chest/Shoulder_Right/ShoulderPadCTRL_Right/ShoulderPadBlade_Right
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/Spine/Chest/Shoulder_Right/ShoulderPadCTRL_Right/ShoulderPadBody_Right
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/Spine/Chest/Shoulder_Right/UpperArm_Right
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/Spine/Chest/Shoulder_Right/UpperArm_Right/LowerArm_Right
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/Spine/Chest/Shoulder_Right/UpperArm_Right/LowerArm_Right/Hand_Right
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/Spine/Chest/Shoulder_Right/UpperArm_Right/LowerArm_Right/Hand_Right/Index_Proximal_Right
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/Spine/Chest/Shoulder_Right/UpperArm_Right/LowerArm_Right/Hand_Right/Index_Proximal_Right/Index_Intermediate_Right
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/Spine/Chest/Shoulder_Right/UpperArm_Right/LowerArm_Right/Hand_Right/Index_Proximal_Right/Index_Intermediate_Right/Index_Distal_Right
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/Spine/Chest/Shoulder_Right/UpperArm_Right/LowerArm_Right/Hand_Right/RestOfFingers_Proximal_Right
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/Spine/Chest/Shoulder_Right/UpperArm_Right/LowerArm_Right/Hand_Right/RestOfFingers_Proximal_Right/RestOfFingers_Intermediate_Right
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/Spine/Chest/Shoulder_Right/UpperArm_Right/LowerArm_Right/Hand_Right/RestOfFingers_Proximal_Right/RestOfFingers_Intermediate_Right/RestOfFingers_Distal_Right
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/Spine/Chest/Shoulder_Right/UpperArm_Right/LowerArm_Right/Hand_Right/Thumb_Proximal_Right
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/Spine/Chest/Shoulder_Right/UpperArm_Right/LowerArm_Right/Hand_Right/Thumb_Proximal_Right/Thumb_Intermediate_Right
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/Spine/Chest/Shoulder_Right/UpperArm_Right/LowerArm_Right/Hand_Right/Thumb_Proximal_Right/Thumb_Intermediate_Right/Thumb_Distal_Right
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/UpperLeg_Left
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/UpperLeg_Left/LowerLeg_Left
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/UpperLeg_Left/LowerLeg_Left/Foot_Left
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/UpperLeg_Left/LowerLeg_Left/Foot_Left/Toe_Left
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/UpperLeg_Left/LowerLeg_Left/Foot_Left/Toe_Left/Toetip_Left
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/UpperLeg_Right
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/UpperLeg_Right/LowerLeg_Right
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/UpperLeg_Right/LowerLeg_Right/Foot_Right
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/UpperLeg_Right/LowerLeg_Right/Foot_Right/Toe_Right
|
||||
m_Weight: 1
|
||||
- m_Path: Hips/UpperLeg_Right/LowerLeg_Right/Foot_Right/Toe_Right/Toetip_Right
|
||||
m_Weight: 1
|
||||
- m_Path: Leg1
|
||||
m_Weight: 1
|
8
Assets/Scripts/Animators/Leonid Animator/UpperBody.mask.meta
generated
Normal file
8
Assets/Scripts/Animators/Leonid Animator/UpperBody.mask.meta
generated
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 368b178fc56a14549b588ee80c7cbf81
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 31900000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
118
Assets/Scripts/Bots/CharacterFactory.cs
Normal file
118
Assets/Scripts/Bots/CharacterFactory.cs
Normal file
@ -0,0 +1,118 @@
|
||||
using System.Collections.Generic;
|
||||
using Unity.Barracuda;
|
||||
using Unity.MLAgents.Policies;
|
||||
using UnityEngine;
|
||||
|
||||
public class CharacterFactory : MonoBehaviour
|
||||
{
|
||||
private static CharacterFactory instance;
|
||||
public static CharacterFactory Instance => instance;
|
||||
|
||||
[SerializeField] private List<NavPoint> spawnPointsForDefendersTeam;
|
||||
[SerializeField] private List<NavPoint> spawnPointsForAttackersTeam;
|
||||
[SerializeField] private GameObject AIPrefab;
|
||||
[SerializeField] private GameObject PlayerPrefab;
|
||||
|
||||
private List<GameObject> bots = new List<GameObject>();
|
||||
public GameObject player { get; private set; }
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (instance == null)
|
||||
instance = this;
|
||||
else
|
||||
{
|
||||
Destroy(gameObject);
|
||||
Debug.LogError("Only 1 Instance");
|
||||
}
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
var attcNum = SettingsReader.Instance.GetSettings.NumOfAttackers;
|
||||
var defNum = SettingsReader.Instance.GetSettings.NumOfDefenders;
|
||||
var humanDef = SettingsReader.Instance.GetSettings.HasHumanDefender == true ? 1 : 0;
|
||||
var humanAtc = SettingsReader.Instance.GetSettings.HasHumanAttacker == true ? 1 : 0;
|
||||
|
||||
if (humanAtc == 1 && humanDef == 1)
|
||||
throw new System.ArgumentException("Can be only one human player");
|
||||
|
||||
for (int i = 0; i < attcNum - humanAtc; i++)
|
||||
InstanciateEntity(Team.Attackers, TypeAI.D0DiskAI,
|
||||
spawnPointsForAttackersTeam[Random.Range(0, spawnPointsForAttackersTeam.Count)]);
|
||||
for (int i = 0; i < defNum - humanDef; i++)
|
||||
InstanciateEntity(Team.Defenders, TypeAI.D0DiskAI,
|
||||
spawnPointsForDefendersTeam[Random.Range(0, spawnPointsForDefendersTeam.Count)]);
|
||||
if (humanAtc == 1)
|
||||
InstanciateEntity(Team.Attackers, TypeAI.HumanAI,
|
||||
spawnPointsForAttackersTeam[Random.Range(0, spawnPointsForAttackersTeam.Count)]);
|
||||
if (humanDef == 1)
|
||||
InstanciateEntity(Team.Defenders, TypeAI.HumanAI,
|
||||
spawnPointsForDefendersTeam[Random.Range(0, spawnPointsForDefendersTeam.Count)]);
|
||||
|
||||
GameManager.OnResetScene += ResetCharacters;
|
||||
}
|
||||
|
||||
private void InstanciateEntity(Team team, TypeAI typeAi, NavPoint spawnPoint)
|
||||
{
|
||||
var gameobject = GameObject.Instantiate(
|
||||
typeAi == TypeAI.HumanAI ? PlayerPrefab : AIPrefab,
|
||||
spawnPoint.Position,
|
||||
Quaternion.identity);
|
||||
gameobject.SetActive(true);
|
||||
if (team == Team.Attackers)
|
||||
gameObject.tag = "Attacker";
|
||||
else
|
||||
gameObject.tag = "Defender";
|
||||
|
||||
if (typeAi == TypeAI.HumanAI)
|
||||
{
|
||||
gameobject.GetComponent<Player>().GetCharacter.Team = team;
|
||||
player = gameobject;
|
||||
}
|
||||
else
|
||||
{
|
||||
var npc = gameobject.GetComponent<NPC>();
|
||||
npc.GetCharacter.Team = team;
|
||||
npc.SetModel(team.ToString(), ScriptableObject.CreateInstance<NNModel>(), InferenceDevice.Default );
|
||||
gameobject.GetComponent<MovementController>().PointStartID = spawnPoint.PointId;
|
||||
bots.Add(gameobject);
|
||||
}
|
||||
}
|
||||
|
||||
public void ReSpawn(ICharacter character, ref Vector3 pos, ref int startPointId)
|
||||
{
|
||||
character.ResetCharacter();
|
||||
var team = character.GetCharacter.Team;
|
||||
NavPoint navPoint;
|
||||
if (team == Team.Attackers)
|
||||
navPoint = spawnPointsForAttackersTeam[Random.Range(0, spawnPointsForAttackersTeam.Count)];
|
||||
else
|
||||
navPoint = spawnPointsForDefendersTeam[Random.Range(0, spawnPointsForDefendersTeam.Count)];
|
||||
|
||||
pos = navPoint.Position;
|
||||
startPointId = navPoint.PointId;
|
||||
}
|
||||
|
||||
private void ResetCharacters()
|
||||
{
|
||||
foreach (var bot in bots)
|
||||
{
|
||||
var npc = bot.GetComponent<NPC>();
|
||||
npc.ResetCharacter();
|
||||
if (npc.GetCharacter.Team == Team.Attackers)
|
||||
bot.transform.position = spawnPointsForAttackersTeam[Random.Range(0, spawnPointsForAttackersTeam.Count)].Position;
|
||||
else
|
||||
bot.transform.position = spawnPointsForDefendersTeam[Random.Range(0, spawnPointsForDefendersTeam.Count)].Position;
|
||||
}
|
||||
Player player;
|
||||
if (TryGetComponent<Player>(out player))
|
||||
{
|
||||
player.ResetCharacter();
|
||||
if (player.GetCharacter.Team == Team.Attackers)
|
||||
this.player.transform.position = spawnPointsForAttackersTeam[Random.Range(0, spawnPointsForAttackersTeam.Count)].Position;
|
||||
else
|
||||
this.player.transform.position = spawnPointsForDefendersTeam[Random.Range(0, spawnPointsForDefendersTeam.Count)].Position;
|
||||
}
|
||||
}
|
||||
}
|
0
Assets/Scripts/Bots/CharacterPooler.cs.meta → Assets/Scripts/Bots/CharacterFactory.cs.meta
generated
Executable file → Normal file
0
Assets/Scripts/Bots/CharacterPooler.cs.meta → Assets/Scripts/Bots/CharacterFactory.cs.meta
generated
Executable file → Normal file
@ -1,4 +0,0 @@
|
||||
public class CharacterPooler
|
||||
{
|
||||
|
||||
}
|
@ -2,4 +2,15 @@
|
||||
{
|
||||
Defenders,
|
||||
Attackers,
|
||||
}
|
||||
|
||||
public static class TeamExtension
|
||||
{
|
||||
public static Team GetOppositeTeam(this Team team)
|
||||
{
|
||||
if (team == Team.Attackers)
|
||||
return Team.Defenders;
|
||||
else
|
||||
return Team.Attackers;
|
||||
}
|
||||
}
|
3
Assets/Scripts/CameraScripts.meta
generated
Normal file
3
Assets/Scripts/CameraScripts.meta
generated
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 563fa8c0f982459e8a6357c9f9078744
|
||||
timeCreated: 1652086279
|
61
Assets/Scripts/CameraScripts/CameraHandler.cs
Normal file
61
Assets/Scripts/CameraScripts/CameraHandler.cs
Normal file
@ -0,0 +1,61 @@
|
||||
using System;
|
||||
using Unity.Mathematics;
|
||||
using UnityEngine;
|
||||
|
||||
namespace CameraScripts
|
||||
{
|
||||
public class CameraHandler : MonoBehaviour
|
||||
{
|
||||
public Transform targetTransform;
|
||||
public Transform cameraTransform;
|
||||
public Transform cameraPivotTransform;
|
||||
private Transform _myTransform;
|
||||
private Vector3 _cameraTransformPosition;
|
||||
private LayerMask ignoreLayers = ~(1 << 8 | 1 << 9 | 1 << 10);
|
||||
|
||||
public static CameraHandler Singleton;
|
||||
|
||||
public const float LookSpeed = 0.1f;
|
||||
public const float FollowSpeed = 0.1f;
|
||||
public const float PivotSpeed = 0.03f;
|
||||
|
||||
private float _defaultPosition;
|
||||
private float _lookAngle;
|
||||
private float _pivotAngle;
|
||||
|
||||
public float minimumPivot = -35;
|
||||
public float maximumPivot = 35;
|
||||
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
Application.targetFrameRate = 60;
|
||||
Singleton = this;
|
||||
_myTransform = transform;
|
||||
_defaultPosition = _myTransform.localPosition.z;
|
||||
}
|
||||
|
||||
public void TargetPosition(float delta)
|
||||
{
|
||||
var toTargetPosition = Vector3.Lerp(_myTransform.position, targetTransform.position, delta /FollowSpeed);
|
||||
_myTransform.position = toTargetPosition;
|
||||
}
|
||||
|
||||
public void HandleCameraRotation(float delta, float mouseX, float mouseY)
|
||||
{
|
||||
_lookAngle += (mouseX * LookSpeed) / delta;
|
||||
_pivotAngle -= (mouseY * PivotSpeed) / delta;
|
||||
_pivotAngle = Mathf.Clamp(_pivotAngle, minimumPivot, maximumPivot);
|
||||
|
||||
var rotation = Vector3.zero;
|
||||
rotation.y = _lookAngle;
|
||||
var targetRotation = Quaternion.Euler(rotation);
|
||||
_myTransform.rotation = targetRotation;
|
||||
|
||||
rotation = Vector3.zero;
|
||||
rotation.x = _pivotAngle;
|
||||
targetRotation = Quaternion.Euler(rotation);
|
||||
cameraPivotTransform.localRotation = targetRotation;
|
||||
}
|
||||
}
|
||||
}
|
3
Assets/Scripts/CameraScripts/CameraHandler.cs.meta
generated
Normal file
3
Assets/Scripts/CameraScripts/CameraHandler.cs.meta
generated
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3d606407023147d7b4d530a9593e9697
|
||||
timeCreated: 1652086288
|
12
Assets/Scripts/Character/Character.cs
Normal file
12
Assets/Scripts/Character/Character.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using UnityEngine;
|
||||
public class Character
|
||||
{
|
||||
public Team Team { get; set; }
|
||||
public float LastTimeHit = 0;
|
||||
public CharacterCondition Condition;
|
||||
|
||||
public Character()
|
||||
{
|
||||
Condition = new CharacterCondition();
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4599c57bc5b1c3945847dead0f9f0ba4
|
||||
guid: 44d6a17ad31b31241928e1a17e9aba37
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
@ -1,12 +1,6 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
public enum NPCState
|
||||
{
|
||||
InCover,
|
||||
InBlancPoint,
|
||||
InRunning,
|
||||
}
|
||||
|
||||
public class CharacterCondition
|
||||
{
|
||||
@ -25,7 +19,18 @@ public class CharacterCondition
|
||||
{
|
||||
health = value;
|
||||
OnChangeHealthEvent?.Invoke(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int GetHealthPointsInQuantile()
|
||||
{
|
||||
if (health < 25)
|
||||
return 0;
|
||||
else if (health < 50)
|
||||
return 1;
|
||||
else if (health < 75)
|
||||
return 2;
|
||||
else return 3;
|
||||
}
|
||||
private int armour;
|
||||
public int ArmourPoints
|
||||
@ -40,6 +45,17 @@ public class CharacterCondition
|
||||
OnChangeArmourEvent?.Invoke(value);
|
||||
}
|
||||
}
|
||||
public int GetArmourPointsInQuantile()
|
||||
{
|
||||
if (armour < 25)
|
||||
return 0;
|
||||
else if (armour < 50)
|
||||
return 1;
|
||||
else if (armour < 75)
|
||||
return 2;
|
||||
else return 3;
|
||||
}
|
||||
|
||||
private int ammo;
|
||||
public int Ammunition
|
||||
{
|
||||
@ -54,15 +70,17 @@ public class CharacterCondition
|
||||
}
|
||||
}
|
||||
|
||||
[HideInInspector]
|
||||
public NPCState npcState { get; private set; }
|
||||
|
||||
public CharacterCondition()
|
||||
{
|
||||
this.Reset();
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
var settings = SettingsReader.Instance.GetSettings;
|
||||
ammo = settings.maxAmmo;
|
||||
health = settings.maxHealth;
|
||||
armour = settings.maxArmour;
|
||||
ammo = settings.MaxAmmo;
|
||||
health = settings.MaxHealth;
|
||||
armour = settings.MaxArmour;
|
||||
}
|
||||
|
||||
public void GiveHealth(int health) => HealthPoints = Mathf.Clamp(health + HealthPoints, 0, 100);
|
||||
|
2
Assets/Scripts/Sensors.meta → Assets/Scripts/Character/Interfaces.meta
generated
Executable file → Normal file
2
Assets/Scripts/Sensors.meta → Assets/Scripts/Character/Interfaces.meta
generated
Executable file → Normal file
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5e73ba257bc6b684c86edf9ecfd475ef
|
||||
guid: f23b6db3be1e4cd469fd18dfe3e39764
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
5
Assets/Scripts/Character/Interfaces/ICharacter.cs
Normal file
5
Assets/Scripts/Character/Interfaces/ICharacter.cs
Normal file
@ -0,0 +1,5 @@
|
||||
public interface ICharacter
|
||||
{
|
||||
Character GetCharacter { get; }
|
||||
void ResetCharacter();
|
||||
}
|
2
Assets/Scripts/Character/scr_Models.cs.meta → Assets/Scripts/Character/Interfaces/ICharacter.cs.meta
generated
Executable file → Normal file
2
Assets/Scripts/Character/scr_Models.cs.meta → Assets/Scripts/Character/Interfaces/ICharacter.cs.meta
generated
Executable file → Normal file
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 907ff02de47a55a4e971d73d25e7d006
|
||||
guid: b6dfb78244ae35c4db1326d5f5b73375
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
17
Assets/Scripts/Character/Interfaces/INpcBaseState.cs
Normal file
17
Assets/Scripts/Character/Interfaces/INpcBaseState.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using UnityEngine;
|
||||
|
||||
public interface INpcBaseState
|
||||
{
|
||||
NpcEnumState State { get; }
|
||||
bool InCover { get; }
|
||||
bool IsRunning { get; }
|
||||
bool InDirectPoint { get; }
|
||||
float HitChance { get; }
|
||||
float DoDamageChance { get; }
|
||||
}
|
||||
|
||||
public interface INpcBaseBodyState
|
||||
{
|
||||
NpcBodyState State { get; }
|
||||
Vector3 GetPointToHit(GameObject go);
|
||||
}
|
11
Assets/Scripts/Character/Interfaces/INpcBaseState.cs.meta
generated
Normal file
11
Assets/Scripts/Character/Interfaces/INpcBaseState.cs.meta
generated
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 58b7e1962495ada4c8e6ee6219c99a20
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
87
Assets/Scripts/Character/MovementController.cs
Executable file → Normal file
87
Assets/Scripts/Character/MovementController.cs
Executable file → Normal file
@ -1,40 +1,83 @@
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AI;
|
||||
|
||||
[RequireComponent(typeof(NavMeshAgent))]
|
||||
public class MovementController : MonoBehaviour
|
||||
{
|
||||
public NavPoint currentPosition { get; private set; }
|
||||
public int PointStartID { get; set; }
|
||||
public int PointEndID { get; private set; }
|
||||
public float FlagDistance { get; private set; }
|
||||
private const float UpdateFlagPositionDelay = 5;
|
||||
private const float UpdateReachedDestinationDelay = 5;
|
||||
|
||||
[SerializeField] private NavMeshAgent navMeshAgent;
|
||||
[SerializeField] private GameObject flag;
|
||||
public float DistanceToGo { get; private set; }
|
||||
public float RemainingDistance => navMeshAgent.remainingDistance;
|
||||
private Dictionary<int, NavPoint> _idNavPointDict;
|
||||
|
||||
private void Start()
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
navMeshAgent.speed = SettingsReader.Instance.GetSettings.movementSpeed;
|
||||
navMeshAgent.speed = SettingsReader.Instance.GetSettings.MovementSpeed;
|
||||
_idNavPointDict = MapManager.Instance.IDToNavPoint;
|
||||
InvokeRepeating(nameof(UpdateFlagPosition), 0, UpdateFlagPositionDelay);
|
||||
InvokeRepeating(nameof(ReachedDestination), 0, UpdateReachedDestinationDelay);
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
CancelInvoke(nameof(UpdateFlagPosition));
|
||||
CancelInvoke(nameof(ReachedDestination));
|
||||
}
|
||||
|
||||
public void Move()
|
||||
private void UpdateFlagPosition()
|
||||
{
|
||||
var pointCandidate = getPointCandidate();
|
||||
goToNextNavPoint(pointCandidate);
|
||||
FlagDistance = (flag.transform.position - gameObject.transform.position).magnitude;
|
||||
}
|
||||
|
||||
|
||||
public void MoveToRandomPoint()
|
||||
{
|
||||
Debug.Log(MapManager.navPoints == null);
|
||||
goToNextNavPoint(MapManager.navPoints[Random.Range(0, MapManager.navPoints.Count)]);
|
||||
}
|
||||
|
||||
private NavPoint getPointCandidate()
|
||||
{
|
||||
var NavPointsPositions = MapManager.navPoints
|
||||
.Select(point => point.transform.position)
|
||||
.Where(point => (currentPosition.transform.position - point).magnitude <= SettingsReader.Instance.GetSettings.movementSpeed)
|
||||
.ToList();
|
||||
return null;
|
||||
GoToNextNavPoint(MapManager.Instance.NavPoints[Random.Range(0, MapManager.Instance.NavPoints.Count)]);
|
||||
}
|
||||
|
||||
public void goToNextNavPoint(NavPoint destination) =>
|
||||
navMeshAgent.SetDestination(destination.transform.position);
|
||||
public List<NavPoint> GetPointsCandidate()
|
||||
{
|
||||
return MapManager.Instance.NavPoints
|
||||
.Where(point =>
|
||||
(_idNavPointDict[PointStartID].Position - point.Position).magnitude < SettingsReader.Instance.GetSettings.MovementDistance)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public void GoToNextNavPoint(NavPoint destination)
|
||||
{
|
||||
if (navMeshAgent.isStopped == true) navMeshAgent.isStopped = false;
|
||||
PointStartID = PointEndID;
|
||||
PointEndID = destination.PointId;
|
||||
navMeshAgent.SetDestination(destination.Position);
|
||||
DistanceToGo = navMeshAgent.remainingDistance;
|
||||
}
|
||||
|
||||
public void ReturnToStartPoint()
|
||||
{
|
||||
if (navMeshAgent.isStopped == true) navMeshAgent.isStopped = false;
|
||||
navMeshAgent.SetDestination(_idNavPointDict[PointStartID].Position);
|
||||
PointEndID = PointStartID;
|
||||
PointStartID = -1;
|
||||
}
|
||||
|
||||
public void StopOnPath()
|
||||
{
|
||||
navMeshAgent.isStopped = true;
|
||||
PointStartID = -1;
|
||||
PointEndID = -1;
|
||||
}
|
||||
|
||||
public void ReachedDestination()
|
||||
{
|
||||
if ((navMeshAgent.isStopped == false) && (navMeshAgent.velocity.magnitude < 0.1))
|
||||
PointStartID = PointEndID;
|
||||
}
|
||||
}
|
||||
|
206
Assets/Scripts/Character/NPC.cs
Executable file → Normal file
206
Assets/Scripts/Character/NPC.cs
Executable file → Normal file
@ -1,61 +1,213 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Unity.MLAgents;
|
||||
using Unity.MLAgents.Sensors;
|
||||
using Unity.MLAgents.Actuators;
|
||||
using Unity.MLAgents.Sensors;
|
||||
using UnityEngine;
|
||||
|
||||
[RequireComponent(typeof(MovementController))]
|
||||
public class NPC : Agent
|
||||
[RequireComponent(typeof(MovementController),typeof(BufferSensorComponent))]
|
||||
public class NPC : Agent, ICharacter
|
||||
{
|
||||
public Team Team { get; set; }
|
||||
|
||||
[HideInInspector]
|
||||
private float LastTimeHit;
|
||||
private Character AgentCharacter;
|
||||
public CharacterCondition Condition;
|
||||
private FlagZone flagZone = null;
|
||||
|
||||
public MovementController moveController;
|
||||
|
||||
private void Start()
|
||||
public INpcBaseState NpcState { get; private set; }
|
||||
public INpcBaseBodyState NpcBodyState { get; private set; }
|
||||
|
||||
public Character GetCharacter => AgentCharacter;
|
||||
|
||||
private NpcDirectPointState DirectState;
|
||||
private NpcInCoverState CoverState;
|
||||
private NpcRunningState RunningState;
|
||||
|
||||
private NpcStandingState StandingState;
|
||||
private NpcCrouchingState CrouchingState;
|
||||
|
||||
private MovementController moveController;
|
||||
private BufferSensorComponent bufferSensor;
|
||||
|
||||
private Dictionary<int, NavPoint> navPointIdDict;
|
||||
|
||||
#region UnityEvents and ML
|
||||
private void Awake()
|
||||
{
|
||||
Condition = new CharacterCondition();
|
||||
DirectState = new NpcDirectPointState();
|
||||
CoverState = new NpcInCoverState();
|
||||
RunningState = new NpcRunningState();
|
||||
NpcState = DirectState;
|
||||
|
||||
CrouchingState = new NpcCrouchingState();
|
||||
StandingState = new NpcStandingState();
|
||||
NpcBodyState = StandingState;
|
||||
|
||||
AgentCharacter = new Character();
|
||||
Condition = AgentCharacter.Condition;
|
||||
|
||||
moveController = gameObject.GetComponent<MovementController>();
|
||||
bufferSensor = gameObject.GetComponent<BufferSensorComponent>();
|
||||
|
||||
flagZone = GameObject.FindObjectOfType<FlagZone>();
|
||||
if (flagZone is null)
|
||||
Debug.LogError("Flag Is Not Set");
|
||||
|
||||
navPointIdDict = MapManager.Instance.IDToNavPoint;
|
||||
if (navPointIdDict is null)
|
||||
Debug.LogError("Cant Find Nav Point Dictionary");
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
Debug.LogWarning("Pooled object was destroyed");
|
||||
}
|
||||
|
||||
public override void OnEpisodeBegin()
|
||||
{
|
||||
|
||||
if (navPointIdDict is null)
|
||||
Debug.LogError("Cant Find Nav Point Dictionary");
|
||||
|
||||
NpcState = DirectState;
|
||||
flagZone = GameObject.FindObjectOfType<FlagZone>();
|
||||
}
|
||||
|
||||
public override void CollectObservations(VectorSensor sensor)
|
||||
{
|
||||
sensor.AddObservation(Condition.HealthPoints);
|
||||
sensor.AddObservation(Condition.ArmourPoints);
|
||||
sensor.AddObservation(Condition.Ammunition);
|
||||
sensor.AddObservation((int)Condition.npcState);
|
||||
}
|
||||
// Debug.Log("Collect observations called!");
|
||||
navPointIdDict = MapManager.Instance.IDToNavPoint;
|
||||
if (navPointIdDict is null)
|
||||
Debug.LogError("Cant Find Nav Point Dictionary");
|
||||
var candidates = moveController.GetPointsCandidate();
|
||||
|
||||
public override void Heuristic(in ActionBuffers actionsOut)
|
||||
{
|
||||
var discreteActionsOut = actionsOut.DiscreteActions;
|
||||
if (Input.GetKeyDown(KeyCode.W))
|
||||
//common sensors
|
||||
sensor.AddObservation(GameManager.IsHaveSeenByEnemy(AgentCharacter.Team.GetOppositeTeam(),
|
||||
NpcBodyState.GetPointToHit(gameObject)).ToInt());
|
||||
sensor.AddObservation(AgentCharacter.LastTimeHit);
|
||||
sensor.AddObservation((!flagZone.IsNotOccup).ToInt());
|
||||
sensor.AddObservation(Condition.GetHealthPointsInQuantile());
|
||||
sensor.AddObservation(Condition.GetArmourPointsInQuantile());
|
||||
sensor.AddObservation(candidates.Count);
|
||||
sensor.AddObservation(moveController.PointStartID);
|
||||
sensor.AddObservation(moveController.PointEndID);
|
||||
// Debug.Log("Done common!");
|
||||
//state sensors
|
||||
sensor.AddObservation((int)NpcState.State);
|
||||
sensor.AddObservation((int)NpcBodyState.State);
|
||||
sensor.AddObservation(GameManager.IsEnemyNearby(gameObject.transform.position, AgentCharacter.Team));
|
||||
sensor.AddObservation(navPointIdDict[moveController.PointStartID].DeathAttr);
|
||||
sensor.AddObservation(navPointIdDict[moveController.PointEndID].DeathAttr);
|
||||
sensor.AddObservation(moveController.FlagDistance);
|
||||
// Debug.Log("Done state sensors!");
|
||||
|
||||
//point sensors
|
||||
foreach (var point in candidates)
|
||||
{
|
||||
discreteActionsOut[0] = 1;
|
||||
var position = transform.position;
|
||||
bufferSensor.AppendObservation(new float[] {
|
||||
point.DeathAttr,
|
||||
(int)point.navType,
|
||||
//4 flagEnemyDistance
|
||||
GameManager.IsCloserToFlagFromNextNavPoint(point, position).ToInt(),
|
||||
//5 EnemyVsNavPointDistance
|
||||
GameManager.IsCloserToEnemyThanToNextNavPoint(point, position, AgentCharacter.Team.GetOppositeTeam()).ToInt(),
|
||||
//6 Have been seen by enemy in this point
|
||||
GameManager.IsHaveSeenByEnemy(AgentCharacter.Team.GetOppositeTeam(),
|
||||
point.Position).ToInt()
|
||||
});
|
||||
}
|
||||
// Debug.Log("Done collect observations!");
|
||||
}
|
||||
|
||||
public override void OnActionReceived(ActionBuffers actions)
|
||||
{
|
||||
if (actions.DiscreteActions[0] == 1)
|
||||
moveController.MoveToRandomPoint();
|
||||
// Debug.Log("Actions recieved!");
|
||||
var result = actions.DiscreteActions;
|
||||
// Debug.Log(result[0] + " " + result[1]);
|
||||
if (result[0] == 0)
|
||||
{
|
||||
if (navPointIdDict[moveController.PointStartID].navType != NavPointType.Cover)
|
||||
return;
|
||||
NpcState = CoverState;
|
||||
|
||||
switch (result[1])
|
||||
{
|
||||
case 0: Peek(); break;
|
||||
case 1: Cover(); break;
|
||||
case 3: Peek(); moveController.GoToNextNavPoint(navPointIdDict[result[2]]); break;
|
||||
case 4: NpcState = DirectState; break;
|
||||
default: throw new ArgumentException("Undefined Action recieved");
|
||||
}
|
||||
}
|
||||
// Debug.Log(result[0] == 1);
|
||||
if (result[0] == 1)
|
||||
{
|
||||
// Debug.Log("BEFORE SOme shitty if >:(");
|
||||
if (navPointIdDict[moveController.PointStartID].navType != NavPointType.Direction)
|
||||
{
|
||||
// Debug.Log("SOme shitty if >:(");
|
||||
return;
|
||||
}
|
||||
// Debug.Log("FUCK");
|
||||
|
||||
switch (result[1])
|
||||
{
|
||||
case 0: moveController.GoToNextNavPoint(navPointIdDict[result[2]]);
|
||||
NpcState = RunningState; Debug.Log("Go to point " + result[2]);break;
|
||||
case 1: NpcState = DirectState; break;
|
||||
default: throw new ArgumentException("Undefined Action recieved");
|
||||
}
|
||||
}
|
||||
|
||||
if (result[0] == 2)
|
||||
{
|
||||
if (moveController.PointStartID == moveController.PointEndID && moveController.PointEndID != -1)
|
||||
return;
|
||||
switch (result[1])
|
||||
{
|
||||
case 0: moveController.StopOnPath(); NpcState = DirectState; break;
|
||||
case 1: moveController.ReturnToStartPoint(); NpcState = RunningState; break;
|
||||
default: throw new ArgumentException("Undefined Action recieved");
|
||||
}
|
||||
}
|
||||
// Debug.Log("Actions processed!");
|
||||
}
|
||||
#endregion
|
||||
|
||||
public event Action<NpcBodyState> OnChangePosition;
|
||||
private void Peek()
|
||||
{
|
||||
OnChangePosition?.Invoke(global::NpcBodyState.Standing);
|
||||
NpcBodyState = StandingState;
|
||||
}
|
||||
|
||||
public event Action<object> OnKilledEvent;
|
||||
public void GetDamage(float damage)
|
||||
private void Cover()
|
||||
{
|
||||
OnChangePosition?.Invoke(global::NpcBodyState.Crouching);
|
||||
NpcBodyState = CrouchingState;
|
||||
}
|
||||
|
||||
public event Action<int, Team> OnDamageRecieved;
|
||||
public void GetDamage(int damage)
|
||||
{
|
||||
AgentCharacter.LastTimeHit = TimeManager.Instance.CurrentTime;
|
||||
Condition.GiveHealth(-Mathf.RoundToInt(damage * (1 - Condition.ArmourPoints * 0.5f)));
|
||||
Condition.GiveArmour(-Mathf.RoundToInt(Mathf.Sqrt(damage) * 5));
|
||||
OnDamageRecieved?.Invoke(damage, AgentCharacter.Team);
|
||||
|
||||
if (Condition.HealthPoints < 0)
|
||||
OnKilledEvent?.Invoke(this);
|
||||
{
|
||||
MapManager.AddDeathAttributeToPoints(moveController.PointStartID, moveController.PointEndID,
|
||||
moveController.DistanceToGo, moveController.RemainingDistance);
|
||||
var pos = gameObject.transform.position;
|
||||
var id = moveController.PointStartID;
|
||||
CharacterFactory.Instance.ReSpawn(this, ref pos, ref id);
|
||||
}
|
||||
}
|
||||
|
||||
public void ResetCharacter()
|
||||
{
|
||||
Condition.Reset();
|
||||
EndEpisode();
|
||||
}
|
||||
}
|
||||
|
2
Assets/Scripts/Character/NPC.cs.meta
generated
2
Assets/Scripts/Character/NPC.cs.meta
generated
@ -4,7 +4,7 @@ MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
executionOrder: 200
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
|
68
Assets/Scripts/Character/NpcState.cs
Normal file
68
Assets/Scripts/Character/NpcState.cs
Normal file
@ -0,0 +1,68 @@
|
||||
using UnityEngine;
|
||||
|
||||
public enum NpcEnumState
|
||||
{
|
||||
InCover,
|
||||
InDirectPoint,
|
||||
InRunning,
|
||||
}
|
||||
|
||||
public enum NpcBodyState
|
||||
{
|
||||
Crouching,
|
||||
Standing,
|
||||
}
|
||||
|
||||
public class NpcCrouchingState : INpcBaseBodyState
|
||||
{
|
||||
public NpcBodyState State => NpcBodyState.Crouching;
|
||||
|
||||
public Vector3 GetPointToHit(GameObject go)
|
||||
{
|
||||
MeshRenderer meshRenderer;
|
||||
go.TryGetComponent<MeshRenderer>(out meshRenderer);
|
||||
return meshRenderer.bounds.center;
|
||||
}
|
||||
}
|
||||
|
||||
public class NpcStandingState : INpcBaseBodyState
|
||||
{
|
||||
public NpcBodyState State => NpcBodyState.Standing;
|
||||
|
||||
public Vector3 GetPointToHit(GameObject go)
|
||||
{
|
||||
MeshRenderer meshRenderer;
|
||||
go.TryGetComponent<MeshRenderer>(out meshRenderer);
|
||||
return meshRenderer.bounds.center;
|
||||
}
|
||||
}
|
||||
|
||||
public class NpcDirectPointState : INpcBaseState
|
||||
{
|
||||
public bool InCover => false;
|
||||
public bool IsRunning => false;
|
||||
public bool InDirectPoint => false;
|
||||
public float HitChance => SettingsReader.Instance.GetSettings.GetHitChanceInDirectPoint;
|
||||
public float DoDamageChance => SettingsReader.Instance.GetSettings.DoDamageChanceInDirectPoint;
|
||||
public NpcEnumState State => NpcEnumState.InDirectPoint;
|
||||
}
|
||||
|
||||
public class NpcRunningState : INpcBaseState
|
||||
{
|
||||
public bool InCover => false;
|
||||
public bool IsRunning => true;
|
||||
public bool InDirectPoint => false;
|
||||
public float HitChance => SettingsReader.Instance.GetSettings.GetHitChanceInRunning;
|
||||
public float DoDamageChance => SettingsReader.Instance.GetSettings.DoDamageChanceInRunning;
|
||||
public NpcEnumState State => NpcEnumState.InRunning;
|
||||
}
|
||||
|
||||
public class NpcInCoverState : INpcBaseState
|
||||
{
|
||||
public bool InCover => true;
|
||||
public bool IsRunning => false;
|
||||
public bool InDirectPoint => false;
|
||||
public float HitChance => SettingsReader.Instance.GetSettings.GetHitChanceInCover;
|
||||
public float DoDamageChance => SettingsReader.Instance.GetSettings.DoDamageChanceInCover;
|
||||
public NpcEnumState State => NpcEnumState.InCover;
|
||||
}
|
11
Assets/Scripts/Character/NpcState.cs.meta
generated
Normal file
11
Assets/Scripts/Character/NpcState.cs.meta
generated
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a192e433e26797745ad0b46de2586de3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
38
Assets/Scripts/Character/Player.cs
Normal file
38
Assets/Scripts/Character/Player.cs
Normal file
@ -0,0 +1,38 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
public class Player : MonoBehaviour, ICharacter
|
||||
{
|
||||
[HideInInspector]
|
||||
public Character PlayerCharacter;
|
||||
public CharacterCondition Condition;
|
||||
|
||||
public Character GetCharacter => PlayerCharacter;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
PlayerCharacter = new Character();
|
||||
Condition = PlayerCharacter.Condition;
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
Debug.LogWarning("Pooled object was destroyed");
|
||||
}
|
||||
|
||||
public event Action<object> OnKilledEvent;
|
||||
public void GetDamage(float damage)
|
||||
{
|
||||
PlayerCharacter.LastTimeHit = TimeManager.Instance.CurrentTime;
|
||||
Condition.GiveHealth(-Mathf.RoundToInt(damage * (1 - Condition.ArmourPoints * 0.5f)));
|
||||
Condition.GiveArmour(-Mathf.RoundToInt(Mathf.Sqrt(damage) * 5));
|
||||
|
||||
if (Condition.HealthPoints < 0)
|
||||
OnKilledEvent?.Invoke(this);
|
||||
}
|
||||
|
||||
public void ResetCharacter()
|
||||
{
|
||||
Condition = new CharacterCondition();
|
||||
}
|
||||
}
|
11
Assets/Scripts/Character/Player.cs.meta
generated
Normal file
11
Assets/Scripts/Character/Player.cs.meta
generated
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a8c9a8e604d395c4ab9d03d28adc4982
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -1,82 +0,0 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
public static class scr_Models
|
||||
{
|
||||
#region Player
|
||||
|
||||
public enum PlayerStance
|
||||
{
|
||||
Stand,
|
||||
Crouch,
|
||||
Prone
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class PlayerSettingsModel
|
||||
{
|
||||
[Header("View Settings")]
|
||||
public float ViewXSensetivity;
|
||||
public float ViewYSensetivity;
|
||||
|
||||
public bool ViewXInverted;
|
||||
public bool ViewYInverted;
|
||||
|
||||
[Header("Movement Settings")]
|
||||
public bool SprintingHold;
|
||||
public float MovementSmoothing;
|
||||
|
||||
[Header("Movement - Running")]
|
||||
public float RunningForwardSpeed;
|
||||
public float RunningStrafeSpeed;
|
||||
|
||||
[Header("Movement - Walking")]
|
||||
public float WalkingForwardSpeed;
|
||||
public float WalkingBackwardSpeed;
|
||||
public float WalkingStrafeSpeed;
|
||||
|
||||
[Header("Jumping")]
|
||||
public float JumpingHeight;
|
||||
public float JumpingFalloff;
|
||||
public float FallingSmoothing;
|
||||
|
||||
[Header("Speed Effectors")]
|
||||
public float SpeedEffector = 1;
|
||||
public float CrouchSpeedEffector;
|
||||
public float ProneSpeedEffector;
|
||||
public float FallingSpeedEffector;
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class CharacterStance
|
||||
{
|
||||
public float CameraHeight;
|
||||
public CapsuleCollider StanceCollider;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region - Weapons -
|
||||
|
||||
[Serializable]
|
||||
public class WeaponSettingsModel
|
||||
{
|
||||
[Header("Weapon Sway")]
|
||||
public float SwayAmount;
|
||||
public bool SwayYInverted;
|
||||
public bool SwayXInverted;
|
||||
public float SwaySmoothing;
|
||||
public float SwayResetSmoothing;
|
||||
public float SwayClampX;
|
||||
public float SwayClampY;
|
||||
|
||||
[Header("Weapon Movement Sway")]
|
||||
public float MovementSwayX;
|
||||
public float MovementSwayY;
|
||||
public bool MovementSwayYInverted;
|
||||
public bool MovementSwayXInverted;
|
||||
public float MovementSwaySmoothing;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
@ -1,57 +1,150 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditorInternal;
|
||||
using System;
|
||||
using Unity.MLAgents;
|
||||
using UnityEngine;
|
||||
|
||||
public class GameManager : MonoBehaviour
|
||||
{
|
||||
|
||||
private static GameManager instance;
|
||||
public static GameManager Instance { get { return instance; } }
|
||||
public static GameManager Instance => instance;
|
||||
|
||||
private static SimpleMultiAgentGroup defendersTeam = new SimpleMultiAgentGroup();
|
||||
private static SimpleMultiAgentGroup attackersTeam = new SimpleMultiAgentGroup();
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (Instance == null)
|
||||
if (instance is null)
|
||||
instance = this;
|
||||
else if (Instance == this)
|
||||
else
|
||||
{
|
||||
Destroy(gameObject);
|
||||
Debug.LogError("Only 1 Instance");
|
||||
}
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
GlobalEventManager.onCaptureFlag += flagCaptured;
|
||||
GlobalEventManager.onTimeLeft += timeOut;
|
||||
}
|
||||
Academy.Instance.OnEnvironmentReset += ResetScene;
|
||||
GlobalEventManager.OnCaptureFlag += FlagCaptured;
|
||||
GlobalEventManager.OnTimeLeft += TimeOut;
|
||||
|
||||
private void Update()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void flagCaptured(Team team)
|
||||
{
|
||||
switch(team)
|
||||
var agents = GameObject.FindObjectsOfType<Agent>();
|
||||
foreach (var item in agents)
|
||||
{
|
||||
case Team.Attackers:
|
||||
Debug.Log("Attackers Win");
|
||||
break;
|
||||
case Team.Defenders:
|
||||
Debug.Log("Defenders Win");
|
||||
break;
|
||||
default:
|
||||
Debug.LogError("Unexpected Team");
|
||||
break;
|
||||
var agent = item as NPC;
|
||||
if (agent.GetCharacter.Team == Team.Attackers)
|
||||
attackersTeam.RegisterAgent(item);
|
||||
else
|
||||
defendersTeam.RegisterAgent(item);
|
||||
}
|
||||
}
|
||||
|
||||
private void timeOut()
|
||||
private static SimpleMultiAgentGroup getAgentList(Team team)
|
||||
{
|
||||
Debug.Log("Time is out");
|
||||
if (team == Team.Attackers)
|
||||
return attackersTeam;
|
||||
else
|
||||
return defendersTeam;
|
||||
}
|
||||
|
||||
public static bool IsCloserToEnemyThanToNextNavPoint(NavPoint navPoint, Vector3 currentTransform, Team oppositeTeam)
|
||||
{
|
||||
var agentGroup = getAgentList(oppositeTeam);
|
||||
|
||||
var distToNavPoint = (currentTransform - navPoint.Position).magnitude;
|
||||
foreach (var agent in agentGroup.GetRegisteredAgents())
|
||||
if (distToNavPoint > (currentTransform - agent.transform.position).magnitude)
|
||||
return true;
|
||||
if ((SettingsReader.Instance.GetSettings.HasHumanAttacker == true && oppositeTeam == Team.Attackers) ||
|
||||
(SettingsReader.Instance.GetSettings.HasHumanDefender == true && oppositeTeam == Team.Defenders))
|
||||
{
|
||||
if (distToNavPoint > (currentTransform - CharacterFactory.Instance.player.transform.position).magnitude)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool IsEnemyNearby(Vector3 currentTransform, Team oppositeTeam)
|
||||
{
|
||||
var agentGroup = getAgentList(oppositeTeam);
|
||||
|
||||
foreach (var agent in agentGroup.GetRegisteredAgents())
|
||||
if ((currentTransform - agent.transform.position).magnitude < SettingsReader.Instance.GetSettings.ViewDistance)
|
||||
return true;
|
||||
if ((SettingsReader.Instance.GetSettings.HasHumanAttacker == true && oppositeTeam == Team.Attackers) ||
|
||||
(SettingsReader.Instance.GetSettings.HasHumanDefender == true && oppositeTeam == Team.Defenders))
|
||||
{
|
||||
if ((currentTransform - CharacterFactory.Instance.player.transform.position).magnitude < SettingsReader.Instance.GetSettings.ViewDistance)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool IsCloserToFlagFromNextNavPoint(NavPoint navPoint, Vector3 currentTransform)
|
||||
=> navPoint.FlagDistance < (currentTransform - GameObject.FindGameObjectWithTag("Flag").transform.position).magnitude;
|
||||
|
||||
public static bool IsHaveSeenByEnemy(Team oppositeTeam, Vector3 position)
|
||||
{
|
||||
var agentGroup = getAgentList(oppositeTeam);
|
||||
RaycastHit rayHit = new RaycastHit();
|
||||
foreach (var agent in agentGroup.GetRegisteredAgents() )
|
||||
{
|
||||
var npc = agent as NPC;
|
||||
if (Physics.Raycast(position,
|
||||
(npc.NpcBodyState.GetPointToHit(npc.gameObject) - position).normalized,
|
||||
out rayHit,
|
||||
SettingsReader.Instance.GetSettings.ViewDistance))
|
||||
{
|
||||
if (rayHit.collider.gameObject.GetComponent<ICharacter>() != null)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if ((SettingsReader.Instance.GetSettings.HasHumanAttacker == true && oppositeTeam == Team.Attackers) ||
|
||||
(SettingsReader.Instance.GetSettings.HasHumanDefender == true && oppositeTeam == Team.Defenders))
|
||||
{
|
||||
var player = CharacterFactory.Instance.player;
|
||||
if (Physics.Raycast(position,
|
||||
(player.GetComponent<MeshRenderer>().bounds.center - position).normalized,
|
||||
out rayHit,
|
||||
SettingsReader.Instance.GetSettings.ViewDistance))
|
||||
{
|
||||
if (rayHit.collider.gameObject.GetComponent<ICharacter>() != null)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void FlagCaptured(Team team)
|
||||
{
|
||||
switch (team)
|
||||
{
|
||||
case Team.Attackers:
|
||||
Debug.Log("Attackers Win");
|
||||
ResetScene();
|
||||
break;
|
||||
case Team.Defenders:
|
||||
Debug.Log("Defenders Win");
|
||||
ResetScene();
|
||||
break;
|
||||
}
|
||||
ResetScene();
|
||||
}
|
||||
|
||||
private void TimeOut()
|
||||
{
|
||||
ResetScene();
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
GlobalEventManager.onCaptureFlag -= flagCaptured;
|
||||
GlobalEventManager.onTimeLeft -= timeOut;
|
||||
GlobalEventManager.OnCaptureFlag -= FlagCaptured;
|
||||
GlobalEventManager.OnTimeLeft -= TimeOut;
|
||||
}
|
||||
|
||||
public static event Action OnResetScene;
|
||||
private void ResetScene()
|
||||
{
|
||||
Debug.Log("Scene Reset");
|
||||
OnResetScene?.Invoke();
|
||||
}
|
||||
}
|
||||
|
@ -2,18 +2,18 @@
|
||||
|
||||
public class GlobalEventManager
|
||||
{
|
||||
public static event Action<Team> onCaptureFlag;
|
||||
public static event Action<Team> OnCaptureFlag;
|
||||
|
||||
public static void SendCaptureFlag(Team team)
|
||||
{
|
||||
onCaptureFlag?.Invoke(team);
|
||||
onCaptureFlag = null;
|
||||
OnCaptureFlag?.Invoke(team);
|
||||
OnCaptureFlag = null;
|
||||
}
|
||||
|
||||
public static event Action onTimeLeft;
|
||||
public static event Action OnTimeLeft;
|
||||
public static void SendTimeout()
|
||||
{
|
||||
onTimeLeft?.Invoke();
|
||||
onTimeLeft = null;
|
||||
OnTimeLeft?.Invoke();
|
||||
OnTimeLeft = null;
|
||||
}
|
||||
}
|
||||
|
@ -3,15 +3,61 @@ using UnityEngine;
|
||||
|
||||
public class MapManager : MonoBehaviour
|
||||
{
|
||||
public static List<NavPoint> navPoints { get; private set; }
|
||||
private void Start()
|
||||
private static MapManager _instance;
|
||||
public static MapManager Instance => _instance;
|
||||
[SerializeField] private List<NavPoint> _navPoints;
|
||||
public List<NavPoint> NavPoints { get => _navPoints; private set => _navPoints = value; }
|
||||
public Dictionary<int, NavPoint> IDToNavPoint {get; private set; }
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
navPoints = new List<NavPoint>();
|
||||
var navPointsGameObj = GameObject.FindGameObjectsWithTag("Point");
|
||||
foreach (var gameobj in navPointsGameObj)
|
||||
if (_instance is null)
|
||||
_instance = this;
|
||||
else
|
||||
{
|
||||
Debug.Log(" a ");
|
||||
navPoints.Add(gameobj.GetComponent<NavPoint>());
|
||||
Destroy(gameObject);
|
||||
Debug.LogError("Only 1 Instance");
|
||||
}
|
||||
|
||||
NavPoints = new List<NavPoint>();
|
||||
var navPointSet = GameObject.Find("NavPoint Set");
|
||||
var count = navPointSet.transform.childCount;
|
||||
for (var i=0; i < count; i++)
|
||||
NavPoints.Add(navPointSet.transform.GetChild(i)
|
||||
.gameObject.GetComponent<NavPoint>());
|
||||
print(NavPoints.Count);
|
||||
NavPointSetToID();
|
||||
}
|
||||
|
||||
|
||||
private void NavPointSetToID()
|
||||
{
|
||||
IDToNavPoint = new Dictionary<int, NavPoint>();
|
||||
int i = 0;
|
||||
foreach (var navPoint in NavPoints)
|
||||
{
|
||||
IDToNavPoint.Add(i, navPoint);
|
||||
navPoint.PointId = i;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
public static void AddDeathAttributeToPoints(int startPoint, int endPoint,
|
||||
float allDistance, float remainingDistance)
|
||||
{
|
||||
var startNavPoint = _instance.IDToNavPoint[startPoint];
|
||||
var endNavPoint = _instance.IDToNavPoint[endPoint];
|
||||
float coef;
|
||||
try
|
||||
{
|
||||
coef = remainingDistance / allDistance;
|
||||
}
|
||||
catch (System.ArithmeticException)
|
||||
{
|
||||
Debug.LogError("Path Length is zero");
|
||||
return;
|
||||
}
|
||||
startNavPoint.DeathAttr += 1 - coef;
|
||||
endNavPoint.DeathAttr += coef;
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,11 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine;
|
||||
|
||||
public class TimeManager : MonoBehaviour
|
||||
{
|
||||
public static TimeManager instance = null;
|
||||
public float CurrentTime;
|
||||
private static TimeManager instance;
|
||||
public static TimeManager Instance { get { return instance; } }
|
||||
|
||||
public float CurrentTime { get; private set; }
|
||||
void Start()
|
||||
{
|
||||
if (instance == null)
|
||||
@ -15,12 +15,14 @@ public class TimeManager : MonoBehaviour
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("Only one Instance");
|
||||
Debug.LogError("Only 1 Instance");
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
void Update()
|
||||
{
|
||||
CurrentTime += Time.deltaTime;
|
||||
if (CurrentTime > SettingsReader.Instance.GetSettings.TimeOut)
|
||||
GlobalEventManager.SendTimeout();
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,4 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine;
|
||||
|
||||
public class FlagZone : MonoBehaviour
|
||||
{
|
||||
@ -9,14 +7,14 @@ public class FlagZone : MonoBehaviour
|
||||
public float TimeStayDefenders { get; private set; }
|
||||
private int occupDefenders;
|
||||
private int occupAttackers;
|
||||
private bool isOccupBoth => (occupDefenders>0) && (occupAttackers>0);
|
||||
private bool isNotOccup => (occupDefenders == 0) && (occupAttackers == 0);
|
||||
public bool IsOccupBoth => (occupDefenders > 0) && (occupAttackers > 0);
|
||||
public bool IsNotOccup => (occupDefenders == 0) && (occupAttackers == 0);
|
||||
private float timeForWin;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
|
||||
timeForWin = SettingsReader.Instance.GetSettings.timeToWin;
|
||||
timeForWin = SettingsReader.Instance.GetSettings.TimeToWin;
|
||||
TimeStayAttackers = 0;
|
||||
TimeStayDefenders = 0;
|
||||
occupAttackers = 0;
|
||||
@ -24,7 +22,7 @@ public class FlagZone : MonoBehaviour
|
||||
}
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
switch(other.tag)
|
||||
switch (other.tag)
|
||||
{
|
||||
case "Defender":
|
||||
occupDefenders++;
|
||||
@ -54,7 +52,7 @@ public class FlagZone : MonoBehaviour
|
||||
}
|
||||
private void Update()
|
||||
{
|
||||
if (isOccupBoth || isNotOccup)
|
||||
if (IsOccupBoth || IsNotOccup)
|
||||
{
|
||||
TimeStayAttackers = 0;
|
||||
TimeStayDefenders = 0;
|
||||
@ -64,7 +62,7 @@ public class FlagZone : MonoBehaviour
|
||||
{
|
||||
TimeStayAttackers += Time.deltaTime;
|
||||
if (TimeStayAttackers > timeForWin)
|
||||
GlobalEventManager.SendCaptureFlag(Team.Attackers);
|
||||
GlobalEventManager.SendCaptureFlag(Team.Attackers);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1,27 +1,27 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
public enum NavPointType
|
||||
{
|
||||
Cover,
|
||||
Direction,
|
||||
}
|
||||
|
||||
|
||||
public class NavPoint : MonoBehaviour
|
||||
{
|
||||
public Vector3 position => gameObject.transform.position;
|
||||
public Vector3 Position => gameObject.transform.position;
|
||||
public float FlagDistance { get; private set; }
|
||||
[System.NonSerialized] public float DeathAttr;
|
||||
[System.NonSerialized] public List<Vector3> EnemiesSeen;
|
||||
//Here other attributes;
|
||||
|
||||
[SerializeField]
|
||||
public int PointId;
|
||||
[SerializeField] public NavPointType navType;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
//DO NOT DELETE
|
||||
}
|
||||
[HideInInspector] public int PointId = 0;
|
||||
[HideInInspector] public float DeathAttr = 0;
|
||||
[HideInInspector] public List<Vector3> EnemiesSeen = new List<Vector3>();
|
||||
|
||||
private void Start()
|
||||
{
|
||||
FlagDistance = (GameObject.FindGameObjectWithTag("Flag").transform.position - position).magnitude;
|
||||
EnemiesSeen = new List<Vector3>();
|
||||
DeathAttr = 0;
|
||||
FlagDistance = (GameObject.FindGameObjectWithTag("Flag").transform.position - Position).magnitude;
|
||||
}
|
||||
}
|
||||
|
@ -1,30 +1,41 @@
|
||||
using UnityEngine;
|
||||
|
||||
[CreateAssetMenu(fileName ="Game Settings", menuName = "Game/Settings", order = 51)]
|
||||
[CreateAssetMenu(fileName = "Game Settings", menuName = "Game/Settings", order = 51)]
|
||||
public class Settings : ScriptableObject
|
||||
{
|
||||
public bool isTesting;
|
||||
public bool IsTesting;
|
||||
|
||||
public float timeToWin;
|
||||
public float timeOut;
|
||||
public float TimeToWin;
|
||||
public float TimeOut;
|
||||
|
||||
[Header("movement")]
|
||||
public float movementDistance;
|
||||
public float movementSpeed;
|
||||
public float MovementDistance;
|
||||
public float MovementSpeed;
|
||||
|
||||
public TypeAI defTeamAI;
|
||||
public TypeAI atcTeamAI;
|
||||
public int numOfDefenders;
|
||||
public int numOfAttackers;
|
||||
public bool hasHumanDefender;
|
||||
public bool hasHumanAttacker;
|
||||
public TypeAI DefTeamAI;
|
||||
public TypeAI AtcTeamAI;
|
||||
public int NumOfDefenders;
|
||||
public int NumOfAttackers;
|
||||
public bool HasHumanDefender;
|
||||
public bool HasHumanAttacker;
|
||||
|
||||
public int healthPickupAmount;
|
||||
public int armourPickupAmount;
|
||||
public int ammunitionPickupAmount;
|
||||
public int pickupsAmount;
|
||||
public int HealthPickupAmount;
|
||||
public int ArmourPickupAmount;
|
||||
public int AmmunitionPickupAmount;
|
||||
public int PickupsAmount;
|
||||
|
||||
public int maxHealth;
|
||||
public int maxArmour;
|
||||
public int maxAmmo;
|
||||
public int MaxHealth;
|
||||
public int MaxArmour;
|
||||
public int MaxAmmo;
|
||||
|
||||
public float ViewDistance;
|
||||
|
||||
public float GetHitChanceInDirectPoint;
|
||||
public float GetHitChanceInRunning;
|
||||
public float GetHitChanceInCover;
|
||||
public float DoDamageChanceInDirectPoint;
|
||||
public float DoDamageChanceInRunning;
|
||||
public float DoDamageChanceInCover;
|
||||
|
||||
public float CrouchingCoefficient;
|
||||
}
|
||||
|
@ -1,17 +1,21 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine;
|
||||
|
||||
public class SettingsReader : MonoBehaviour
|
||||
{
|
||||
private static SettingsReader instance;
|
||||
public static SettingsReader Instance { get { return instance; } }
|
||||
public static SettingsReader Instance => instance;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
instance = this;
|
||||
if (instance is null)
|
||||
instance = this;
|
||||
else
|
||||
{
|
||||
Destroy(gameObject);
|
||||
Debug.LogError("Only 1 Instance");
|
||||
}
|
||||
}
|
||||
|
||||
[SerializeField] private Settings gameSettings;
|
||||
public Settings GetSettings { get { return gameSettings; } }
|
||||
public Settings GetSettings => gameSettings;
|
||||
}
|
||||
|
@ -1,9 +0,0 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class Statistics : MonoBehaviour
|
||||
{
|
||||
private void Start()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine;
|
||||
|
||||
[RequireComponent(typeof(BoxCollider))]
|
||||
public class AmmoPickUp : MonoBehaviour, IPickable
|
||||
@ -11,9 +10,14 @@ public class AmmoPickUp : MonoBehaviour, IPickable
|
||||
PickObject(other.gameObject);
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
Debug.LogWarning("Pooled object was destroyed");
|
||||
}
|
||||
|
||||
public void PickObject(GameObject obj)
|
||||
{
|
||||
obj.GetComponent<CharacterCondition>()?.TakeAmmo(SettingsReader.Instance.GetSettings.ammunitionPickupAmount);
|
||||
obj.GetComponent<ICharacter>()?.GetCharacter.Condition.TakeAmmo(SettingsReader.Instance.GetSettings.AmmunitionPickupAmount);
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine;
|
||||
|
||||
[RequireComponent(typeof(BoxCollider))]
|
||||
public class ArmourPickUp : MonoBehaviour, IPickable
|
||||
@ -11,9 +10,14 @@ public class ArmourPickUp : MonoBehaviour, IPickable
|
||||
PickObject(other.gameObject);
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
Debug.LogWarning("Pooled object was destroyed");
|
||||
}
|
||||
|
||||
public void PickObject(GameObject obj)
|
||||
{
|
||||
obj.GetComponent<CharacterCondition>()?.GiveArmour(SettingsReader.Instance.GetSettings.armourPickupAmount);
|
||||
obj.GetComponent<ICharacter>()?.GetCharacter.Condition.GiveArmour(SettingsReader.Instance.GetSettings.ArmourPickupAmount);
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine;
|
||||
|
||||
[RequireComponent(typeof(BoxCollider))]
|
||||
public class HealthPickUp : MonoBehaviour, IPickable
|
||||
@ -11,9 +10,14 @@ public class HealthPickUp : MonoBehaviour, IPickable
|
||||
PickObject(other.gameObject);
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
Debug.LogWarning("Pooled object was destroyed");
|
||||
}
|
||||
|
||||
public void PickObject(GameObject obj)
|
||||
{
|
||||
obj.GetComponent<CharacterCondition>()?.GiveHealth(SettingsReader.Instance.GetSettings.healthPickupAmount);
|
||||
obj.GetComponent<ICharacter>()?.GetCharacter.Condition.GiveHealth(SettingsReader.Instance.GetSettings.HealthPickupAmount);
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine;
|
||||
public interface IPickable
|
||||
{
|
||||
PickUpType type { get; }
|
||||
PickUpType type { get; }
|
||||
void PickObject(GameObject obj);
|
||||
}
|
@ -16,10 +16,18 @@ public class PickUpSpawner : MonoBehaviour
|
||||
|
||||
[SerializeField] private List<NavPoint> spawnPoints;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (instance == null)
|
||||
instance = this;
|
||||
else
|
||||
Destroy(gameObject);
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
pickups = new List<GameObject>();
|
||||
var amount = SettingsReader.Instance.GetSettings.pickupsAmount;
|
||||
var amount = SettingsReader.Instance.GetSettings.PickupsAmount;
|
||||
for (int i = 0; i < amount; i++)
|
||||
pickups.Add(GameObject.Instantiate(healthPrefab, spawnPoints[Random.Range(0, spawnPoints.Count)].transform.position, Quaternion.identity));
|
||||
for (int i = 0; i < amount; i++)
|
||||
@ -36,25 +44,25 @@ public class PickUpSpawner : MonoBehaviour
|
||||
|
||||
private IEnumerator SpawnNewPickUps()
|
||||
{
|
||||
while(true)
|
||||
while (true)
|
||||
{
|
||||
GameObject item;
|
||||
if(IsDisableCheck(out item))
|
||||
if (IsDisableCheck(out item))
|
||||
{
|
||||
yield return new WaitForSeconds(3);
|
||||
if (item != null)
|
||||
{
|
||||
item.transform.position = spawnPoints[Random.Range(0, spawnPoints.Count)].position;
|
||||
item.transform.position = spawnPoints[Random.Range(0, spawnPoints.Count)].Position;
|
||||
item.SetActive(true);
|
||||
}
|
||||
}
|
||||
yield return new WaitForSeconds(2);
|
||||
yield return new WaitForSeconds(2);
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsDisableCheck(out GameObject gameobj)
|
||||
{
|
||||
foreach(var pick in pickups)
|
||||
foreach (var pick in pickups)
|
||||
{
|
||||
if (!pick.activeInHierarchy)
|
||||
{
|
||||
|
@ -1,6 +0,0 @@
|
||||
public enum SensorType
|
||||
{
|
||||
Visual,
|
||||
Sound,
|
||||
Other
|
||||
}
|
@ -1,4 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using Unity.MLAgents.Sensors;
|
||||
|
||||
|
8
Assets/Scripts/Statistics.meta
generated
Normal file
8
Assets/Scripts/Statistics.meta
generated
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3a9f7f0a9faf11f49a433480722bffc5
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
19
Assets/Scripts/Statistics/Logger.cs
Normal file
19
Assets/Scripts/Statistics/Logger.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
|
||||
public class Logger
|
||||
{
|
||||
private const string Directory = "/Logs/";
|
||||
private const string BaseName = "Log#";
|
||||
|
||||
public static void SaveLog<T>(T objToSerialize)
|
||||
{
|
||||
var dir = Application.persistentDataPath + Directory;
|
||||
if (!System.IO.Directory.Exists(dir))
|
||||
System.IO.Directory.CreateDirectory(dir);
|
||||
|
||||
var logName = BaseName + (System.IO.Directory.GetFiles(dir).Length + 1).ToString();
|
||||
var json = JsonUtility.ToJson(objToSerialize);
|
||||
File.WriteAllText(dir + logName, json);
|
||||
}
|
||||
}
|
11
Assets/Scripts/Statistics/Logger.cs.meta
generated
Normal file
11
Assets/Scripts/Statistics/Logger.cs.meta
generated
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b3a1cec894fa98b4bbe20470f1e316c4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
51
Assets/Scripts/Statistics/StatisticManager.cs
Normal file
51
Assets/Scripts/Statistics/StatisticManager.cs
Normal file
@ -0,0 +1,51 @@
|
||||
using UnityEngine;
|
||||
|
||||
internal class Log
|
||||
{
|
||||
public int damageTakenByDefs = 0;
|
||||
public int damageTakenByAtc = 0;
|
||||
|
||||
public int AtcWin = 0;
|
||||
public int DefWin = 0;
|
||||
|
||||
public int TimeOuts = 0;
|
||||
}
|
||||
|
||||
public class StatisticManager : MonoBehaviour
|
||||
{
|
||||
private Log log = new Log();
|
||||
private void Awake()
|
||||
{
|
||||
foreach (var npc in GameObject.FindObjectsOfType<NPC>())
|
||||
npc.OnDamageRecieved += RegisterDamage;
|
||||
|
||||
GlobalEventManager.OnCaptureFlag += RegisterWin;
|
||||
GlobalEventManager.OnTimeLeft += RegisterTimeOut;
|
||||
}
|
||||
|
||||
private void RegisterDamage(int damage, Team team)
|
||||
{
|
||||
if (team == Team.Attackers)
|
||||
log.damageTakenByAtc += damage;
|
||||
else
|
||||
log.damageTakenByDefs += damage;
|
||||
}
|
||||
|
||||
private void RegisterWin(Team team)
|
||||
{
|
||||
if (team == Team.Attackers)
|
||||
log.AtcWin += 1;
|
||||
else
|
||||
log.DefWin += 1;
|
||||
}
|
||||
|
||||
private void RegisterTimeOut()
|
||||
{
|
||||
log.TimeOuts += 1;
|
||||
}
|
||||
|
||||
private void OnApplicationQuit()
|
||||
{
|
||||
Logger.SaveLog<Log>(log);
|
||||
}
|
||||
}
|
0
Assets/Scripts/Misc/Statistics.cs.meta → Assets/Scripts/Statistics/StatisticManager.cs.meta
generated
Executable file → Normal file
0
Assets/Scripts/Misc/Statistics.cs.meta → Assets/Scripts/Statistics/StatisticManager.cs.meta
generated
Executable file → Normal file
7
Assets/Scripts/Utils/BoolToInteger.cs
Normal file
7
Assets/Scripts/Utils/BoolToInteger.cs
Normal file
@ -0,0 +1,7 @@
|
||||
public static class BoolExtension
|
||||
{
|
||||
public static int ToInt(this bool _bool)
|
||||
{
|
||||
return _bool == true ? 1 : 0;
|
||||
}
|
||||
}
|
11
Assets/Scripts/Utils/BoolToInteger.cs.meta
generated
Normal file
11
Assets/Scripts/Utils/BoolToInteger.cs.meta
generated
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f48fff3c2eda14d4fba923fe8875f651
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -1,10 +1,10 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using UnityEngine;
|
||||
using System.Linq;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityObject = UnityEngine.Object;
|
||||
|
||||
[Serializable, DebuggerDisplay("Count = {Count}")]
|
||||
|
46
Assets/Scripts/Weapons/WeaponController.cs
Executable file
46
Assets/Scripts/Weapons/WeaponController.cs
Executable file
@ -0,0 +1,46 @@
|
||||
using UnityEngine;
|
||||
public class scr_WeaponController : MonoBehaviour
|
||||
{
|
||||
private scr_CharacterController characterController;
|
||||
[Header("Settings")]
|
||||
public WeaponSettingsModel settings;
|
||||
|
||||
private bool isInitialised;
|
||||
|
||||
Vector3 newWeaponRotation;
|
||||
Vector3 newWeaponRotationVelocity;
|
||||
|
||||
Vector3 targetWeaponRotation;
|
||||
Vector3 targetWeaponRotationVelocity;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
newWeaponRotation = transform.localRotation.eulerAngles;
|
||||
}
|
||||
|
||||
public void Initialise(scr_CharacterController CharacterController)
|
||||
{
|
||||
characterController = CharacterController;
|
||||
isInitialised = true;
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
if (!isInitialised)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
targetWeaponRotation.y += settings.SwayAmount * (settings.SwayXInverted ? -characterController.input_View.x : characterController.input_View.x) * Time.deltaTime;
|
||||
targetWeaponRotation.x += settings.SwayAmount * (settings.SwayYInverted ? characterController.input_View.y : -characterController.input_View.y) * Time.deltaTime;
|
||||
//newWeaponRotation.x = Mathf.Clamp(newWeaponRotation.x, ViewClampYMin, ViewClampYMax);
|
||||
|
||||
targetWeaponRotation.x = Mathf.Clamp(targetWeaponRotation.x, -settings.SwayClampX, settings.SwayClampX);
|
||||
targetWeaponRotation.y = Mathf.Clamp(targetWeaponRotation.y, -settings.SwayClampY, settings.SwayClampY);
|
||||
|
||||
targetWeaponRotation = Vector3.SmoothDamp(targetWeaponRotation, Vector3.zero, ref targetWeaponRotationVelocity, settings.SwayResetSmoothing);
|
||||
newWeaponRotation = Vector3.SmoothDamp(newWeaponRotation, targetWeaponRotation, ref newWeaponRotationVelocity, settings.SwaySmoothing);
|
||||
|
||||
transform.localRotation = Quaternion.Euler(newWeaponRotation);
|
||||
}
|
||||
}
|
0
Assets/Scripts/Weapons/scr_WeaponController.cs.meta → Assets/Scripts/Weapons/WeaponController.cs.meta
generated
Executable file → Normal file
0
Assets/Scripts/Weapons/scr_WeaponController.cs.meta → Assets/Scripts/Weapons/WeaponController.cs.meta
generated
Executable file → Normal file
@ -1,81 +0,0 @@
|
||||
using System;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
using static scr_Models;
|
||||
|
||||
public class scr_FullCharacterController : MonoBehaviour
|
||||
{
|
||||
private scr_CharacterController characterController;
|
||||
[Header("Settings")]
|
||||
public WeaponSettingsModel settings;
|
||||
|
||||
[Header("References")]
|
||||
public Animator SciFiWarriorOur;
|
||||
|
||||
private bool isInitialised;
|
||||
|
||||
Vector3 newWeaponRotation;
|
||||
Vector3 newWeaponRotationVelocity;
|
||||
|
||||
Vector3 targetWeaponRotation;
|
||||
Vector3 targetWeaponRotationVelocity;
|
||||
|
||||
Vector3 newWeaponMovementRotation;
|
||||
Vector3 newWeaponRotationMovementVelocity;
|
||||
|
||||
Vector3 targetWeaponMovementRotation;
|
||||
Vector3 targetWeaponMovementRotationVelocity;
|
||||
private void Start()
|
||||
{
|
||||
newWeaponRotation = transform.localRotation.eulerAngles;
|
||||
}
|
||||
|
||||
public void Initialise(scr_CharacterController CharacterController)
|
||||
{
|
||||
characterController = CharacterController;
|
||||
isInitialised = true;
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
if (!isInitialised)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
CalculateWeaponRotation();
|
||||
SetWeaponAnimation();
|
||||
}
|
||||
private void CalculateWeaponRotation()
|
||||
{
|
||||
SciFiWarriorOur.speed = characterController.weaponAnimationSpeed;
|
||||
|
||||
targetWeaponRotation.y += settings.SwayAmount * (settings.SwayXInverted ? -characterController.input_View.x : characterController.input_View.x) * Time.deltaTime;
|
||||
targetWeaponRotation.x += settings.SwayAmount * (settings.SwayYInverted ? characterController.input_View.y : -characterController.input_View.y) * Time.deltaTime;
|
||||
//newWeaponRotation.x = Mathf.Clamp(newWeaponRotation.x, ViewClampYMin, ViewClampYMax);
|
||||
|
||||
targetWeaponRotation.x = Mathf.Clamp(targetWeaponRotation.x, -settings.SwayClampX, settings.SwayClampX);
|
||||
targetWeaponRotation.y = Mathf.Clamp(targetWeaponRotation.y, -settings.SwayClampY, settings.SwayClampY);
|
||||
|
||||
targetWeaponRotation.z = targetWeaponRotation.y;
|
||||
|
||||
targetWeaponRotation = Vector3.SmoothDamp(targetWeaponRotation, Vector3.zero, ref targetWeaponRotationVelocity, settings.SwayResetSmoothing);
|
||||
newWeaponRotation = Vector3.SmoothDamp(newWeaponRotation, targetWeaponRotation, ref newWeaponRotationVelocity, settings.SwaySmoothing);
|
||||
|
||||
targetWeaponMovementRotation.z = settings.MovementSwayX * (settings.MovementSwayXInverted ? -characterController.input_Movement.x : characterController.input_Movement.x);
|
||||
targetWeaponMovementRotation.x = settings.MovementSwayY * (settings.MovementSwayYInverted ? -characterController.input_Movement.y : characterController.input_Movement.y);
|
||||
|
||||
targetWeaponMovementRotation = Vector3.SmoothDamp(targetWeaponMovementRotation, Vector3.zero, ref targetWeaponMovementRotationVelocity, settings.SwayResetSmoothing);
|
||||
newWeaponMovementRotation = Vector3.SmoothDamp(newWeaponRotation, targetWeaponMovementRotation, ref newWeaponRotationVelocity, settings.SwaySmoothing);
|
||||
|
||||
|
||||
transform.localRotation = Quaternion.Euler(newWeaponRotation);
|
||||
}
|
||||
|
||||
private void SetWeaponAnimation()
|
||||
{
|
||||
SciFiWarriorOur.SetBool("isSprinting", characterController.isSprinting);
|
||||
SciFiWarriorOur.SetBool("isWalking", characterController.isWalking);
|
||||
}
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d42553a14d6745f9ab94d91cc5e1850a
|
||||
timeCreated: 1650274114
|
@ -1,81 +0,0 @@
|
||||
using System;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
using static scr_Models;
|
||||
|
||||
public class scr_WeaponController : MonoBehaviour
|
||||
{
|
||||
private scr_CharacterController characterController;
|
||||
[Header("Settings")]
|
||||
public WeaponSettingsModel settings;
|
||||
|
||||
[Header("References")]
|
||||
public Animator weaponAnimator;
|
||||
|
||||
private bool isInitialised;
|
||||
|
||||
Vector3 newWeaponRotation;
|
||||
Vector3 newWeaponRotationVelocity;
|
||||
|
||||
Vector3 targetWeaponRotation;
|
||||
Vector3 targetWeaponRotationVelocity;
|
||||
|
||||
Vector3 newWeaponMovementRotation;
|
||||
Vector3 newWeaponRotationMovementVelocity;
|
||||
|
||||
Vector3 targetWeaponMovementRotation;
|
||||
Vector3 targetWeaponMovementRotationVelocity;
|
||||
private void Start()
|
||||
{
|
||||
newWeaponRotation = transform.localRotation.eulerAngles;
|
||||
}
|
||||
|
||||
public void Initialise(scr_CharacterController CharacterController)
|
||||
{
|
||||
characterController = CharacterController;
|
||||
isInitialised = true;
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
if (!isInitialised)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
CalculateWeaponRotation();
|
||||
SetWeaponAnimation();
|
||||
}
|
||||
private void CalculateWeaponRotation()
|
||||
{
|
||||
weaponAnimator.speed = characterController.weaponAnimationSpeed;
|
||||
|
||||
targetWeaponRotation.y += settings.SwayAmount * (settings.SwayXInverted ? -characterController.input_View.x : characterController.input_View.x) * Time.deltaTime;
|
||||
targetWeaponRotation.x += settings.SwayAmount * (settings.SwayYInverted ? characterController.input_View.y : -characterController.input_View.y) * Time.deltaTime;
|
||||
//newWeaponRotation.x = Mathf.Clamp(newWeaponRotation.x, ViewClampYMin, ViewClampYMax);
|
||||
|
||||
targetWeaponRotation.x = Mathf.Clamp(targetWeaponRotation.x, -settings.SwayClampX, settings.SwayClampX);
|
||||
targetWeaponRotation.y = Mathf.Clamp(targetWeaponRotation.y, -settings.SwayClampY, settings.SwayClampY);
|
||||
|
||||
targetWeaponRotation.z = targetWeaponRotation.y;
|
||||
|
||||
targetWeaponRotation = Vector3.SmoothDamp(targetWeaponRotation, Vector3.zero, ref targetWeaponRotationVelocity, settings.SwayResetSmoothing);
|
||||
newWeaponRotation = Vector3.SmoothDamp(newWeaponRotation, targetWeaponRotation, ref newWeaponRotationVelocity, settings.SwaySmoothing);
|
||||
|
||||
targetWeaponMovementRotation.z = settings.MovementSwayX * (settings.MovementSwayXInverted ? -characterController.input_Movement.x : characterController.input_Movement.x);
|
||||
targetWeaponMovementRotation.x = settings.MovementSwayY * (settings.MovementSwayYInverted ? -characterController.input_Movement.y : characterController.input_Movement.y);
|
||||
|
||||
targetWeaponMovementRotation = Vector3.SmoothDamp(targetWeaponMovementRotation, Vector3.zero, ref targetWeaponMovementRotationVelocity, settings.SwayResetSmoothing);
|
||||
newWeaponMovementRotation = Vector3.SmoothDamp(newWeaponRotation, targetWeaponMovementRotation, ref newWeaponRotationVelocity, settings.SwaySmoothing);
|
||||
|
||||
|
||||
transform.localRotation = Quaternion.Euler(newWeaponRotation);
|
||||
}
|
||||
|
||||
private void SetWeaponAnimation()
|
||||
{
|
||||
weaponAnimator.SetBool("isSprinting", characterController.isSprinting);
|
||||
weaponAnimator.SetBool("isWalking", characterController.isSprinting);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user