fixed player in bot fights and their scaled time features (player not time scaled). Now player can join to fights for justice.
This commit is contained in:
@ -139,7 +139,7 @@ public partial class @ThirdPersonViewInput : IInputActionCollection2, IDisposabl
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
""name"": ""Fire"",
|
""name"": ""Fire"",
|
||||||
""type"": ""PassThrough"",
|
""type"": ""Button"",
|
||||||
""id"": ""2b493869-f7ab-4acb-8918-11b0265f0993"",
|
""id"": ""2b493869-f7ab-4acb-8918-11b0265f0993"",
|
||||||
""expectedControlType"": ""Button"",
|
""expectedControlType"": ""Button"",
|
||||||
""processors"": """",
|
""processors"": """",
|
||||||
@ -174,7 +174,7 @@ public partial class @ThirdPersonViewInput : IInputActionCollection2, IDisposabl
|
|||||||
""name"": """",
|
""name"": """",
|
||||||
""id"": ""5caa47c3-a8d5-4aad-86fe-40cdca87210a"",
|
""id"": ""5caa47c3-a8d5-4aad-86fe-40cdca87210a"",
|
||||||
""path"": ""<Mouse>/leftButton"",
|
""path"": ""<Mouse>/leftButton"",
|
||||||
""interactions"": ""Hold(duration=0.1)"",
|
""interactions"": ""Hold"",
|
||||||
""processors"": """",
|
""processors"": """",
|
||||||
""groups"": """",
|
""groups"": """",
|
||||||
""action"": ""Fire"",
|
""action"": ""Fire"",
|
||||||
|
@ -117,7 +117,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Fire",
|
"name": "Fire",
|
||||||
"type": "PassThrough",
|
"type": "Button",
|
||||||
"id": "2b493869-f7ab-4acb-8918-11b0265f0993",
|
"id": "2b493869-f7ab-4acb-8918-11b0265f0993",
|
||||||
"expectedControlType": "Button",
|
"expectedControlType": "Button",
|
||||||
"processors": "",
|
"processors": "",
|
||||||
@ -152,7 +152,7 @@
|
|||||||
"name": "",
|
"name": "",
|
||||||
"id": "5caa47c3-a8d5-4aad-86fe-40cdca87210a",
|
"id": "5caa47c3-a8d5-4aad-86fe-40cdca87210a",
|
||||||
"path": "<Mouse>/leftButton",
|
"path": "<Mouse>/leftButton",
|
||||||
"interactions": "Hold(duration=0.1)",
|
"interactions": "Hold",
|
||||||
"processors": "",
|
"processors": "",
|
||||||
"groups": "",
|
"groups": "",
|
||||||
"action": "Fire",
|
"action": "Fire",
|
||||||
|
37
Assets/Prefabs/BotPrefab/Bot.prefab
generated
37
Assets/Prefabs/BotPrefab/Bot.prefab
generated
@ -151,7 +151,7 @@ Transform:
|
|||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_GameObject: {fileID: 1105574061174270723}
|
m_GameObject: {fileID: 1105574061174270723}
|
||||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
m_LocalPosition: {x: 0, y: 1.42, z: 1.084}
|
m_LocalPosition: {x: 0, y: 1.42, z: 1.316}
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 1740317275426427710}
|
m_Father: {fileID: 1740317275426427710}
|
||||||
@ -1125,7 +1125,6 @@ GameObject:
|
|||||||
- component: {fileID: 1740317275426328325}
|
- component: {fileID: 1740317275426328325}
|
||||||
- component: {fileID: 1740317275426328323}
|
- component: {fileID: 1740317275426328323}
|
||||||
- component: {fileID: 2063326275591512128}
|
- component: {fileID: 2063326275591512128}
|
||||||
- component: {fileID: 9003219069727127243}
|
|
||||||
- component: {fileID: 3763807728217797723}
|
- component: {fileID: 3763807728217797723}
|
||||||
- component: {fileID: 4342955358919846965}
|
- component: {fileID: 4342955358919846965}
|
||||||
- component: {fileID: 8845315550143730895}
|
- component: {fileID: 8845315550143730895}
|
||||||
@ -1134,6 +1133,7 @@ GameObject:
|
|||||||
- component: {fileID: 6609557663758964906}
|
- component: {fileID: 6609557663758964906}
|
||||||
- component: {fileID: 4758249021326882836}
|
- component: {fileID: 4758249021326882836}
|
||||||
- component: {fileID: -190068591826822826}
|
- component: {fileID: -190068591826822826}
|
||||||
|
- component: {fileID: 303563438449043736}
|
||||||
m_Layer: 10
|
m_Layer: 10
|
||||||
m_Name: Bot
|
m_Name: Bot
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
@ -1243,23 +1243,6 @@ MonoBehaviour:
|
|||||||
isFiring: 0
|
isFiring: 0
|
||||||
lookSpeed: 50
|
lookSpeed: 50
|
||||||
fireAnimation: 0
|
fireAnimation: 0
|
||||||
--- !u!114 &9003219069727127243
|
|
||||||
MonoBehaviour:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 1740317275426328350}
|
|
||||||
m_Enabled: 1
|
|
||||||
m_EditorHideFlags: 0
|
|
||||||
m_Script: {fileID: 11500000, guid: 52f87dd051395614ebf0004d18d43bba, type: 3}
|
|
||||||
m_Name:
|
|
||||||
m_EditorClassIdentifier:
|
|
||||||
raycast: {fileID: 1105574061174270723}
|
|
||||||
firePoint: {fileID: 8024036354822949060}
|
|
||||||
projectilePrefab: {fileID: 198792769130808804, guid: 4543ab5e3d405ec40a8d4e9aa5165030,
|
|
||||||
type: 3}
|
|
||||||
audioSource: {fileID: 8172543764818839021}
|
|
||||||
--- !u!195 &3763807728217797723
|
--- !u!195 &3763807728217797723
|
||||||
NavMeshAgent:
|
NavMeshAgent:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -1479,6 +1462,22 @@ AudioSource:
|
|||||||
m_PreInfinity: 2
|
m_PreInfinity: 2
|
||||||
m_PostInfinity: 2
|
m_PostInfinity: 2
|
||||||
m_RotationOrder: 4
|
m_RotationOrder: 4
|
||||||
|
--- !u!114 &303563438449043736
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1740317275426328350}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 2a6ce8ea5e584f40922a36bdb4219494, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
raycast: {fileID: 1740317275426328380}
|
||||||
|
firePoint: {fileID: 1105574061174270723}
|
||||||
|
projectilePrefab: {fileID: 198792769130808804, guid: 4543ab5e3d405ec40a8d4e9aa5165030,
|
||||||
|
type: 3}
|
||||||
--- !u!1 &1740317275426328352
|
--- !u!1 &1740317275426328352
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
45
Assets/Prefabs/PlayerPrefab/Player.prefab
generated
45
Assets/Prefabs/PlayerPrefab/Player.prefab
generated
@ -1394,10 +1394,10 @@ GameObject:
|
|||||||
- component: {fileID: 2528273238195332182}
|
- component: {fileID: 2528273238195332182}
|
||||||
- component: {fileID: 2528273238195332176}
|
- component: {fileID: 2528273238195332176}
|
||||||
- component: {fileID: 2528273238195332168}
|
- component: {fileID: 2528273238195332168}
|
||||||
- component: {fileID: 5170482295850327424}
|
|
||||||
- component: {fileID: 8568640505362233545}
|
- component: {fileID: 8568640505362233545}
|
||||||
- component: {fileID: 5876264296742387244}
|
- component: {fileID: 5876264296742387244}
|
||||||
- component: {fileID: -7092397416598211530}
|
- component: {fileID: -7092397416598211530}
|
||||||
|
- component: {fileID: 1774200722056680610}
|
||||||
m_Layer: 10
|
m_Layer: 10
|
||||||
m_Name: Player
|
m_Name: Player
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
@ -1439,7 +1439,7 @@ Rigidbody:
|
|||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
m_Mass: 1
|
m_Mass: 1
|
||||||
m_Drag: 8
|
m_Drag: 8
|
||||||
m_AngularDrag: 20
|
m_AngularDrag: 0
|
||||||
m_UseGravity: 1
|
m_UseGravity: 1
|
||||||
m_IsKinematic: 0
|
m_IsKinematic: 0
|
||||||
m_Interpolate: 0
|
m_Interpolate: 0
|
||||||
@ -1470,8 +1470,8 @@ Animator:
|
|||||||
m_Enabled: 1
|
m_Enabled: 1
|
||||||
m_Avatar: {fileID: 9000000, guid: 860793eb3324391468f1c120a75ec049, type: 3}
|
m_Avatar: {fileID: 9000000, guid: 860793eb3324391468f1c120a75ec049, type: 3}
|
||||||
m_Controller: {fileID: 9100000, guid: 3ebf60422b6cb1c498ee4cf238072b43, type: 2}
|
m_Controller: {fileID: 9100000, guid: 3ebf60422b6cb1c498ee4cf238072b43, type: 2}
|
||||||
m_CullingMode: 1
|
m_CullingMode: 0
|
||||||
m_UpdateMode: 0
|
m_UpdateMode: 2
|
||||||
m_ApplyRootMotion: 1
|
m_ApplyRootMotion: 1
|
||||||
m_LinearVelocityBlending: 0
|
m_LinearVelocityBlending: 0
|
||||||
m_WarningMessage:
|
m_WarningMessage:
|
||||||
@ -1531,23 +1531,6 @@ MonoBehaviour:
|
|||||||
anim: {fileID: 2528273238195332174}
|
anim: {fileID: 2528273238195332174}
|
||||||
canRotate: 1
|
canRotate: 1
|
||||||
isCrouching: 0
|
isCrouching: 0
|
||||||
--- !u!114 &5170482295850327424
|
|
||||||
MonoBehaviour:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 2528273238195332181}
|
|
||||||
m_Enabled: 1
|
|
||||||
m_EditorHideFlags: 0
|
|
||||||
m_Script: {fileID: 11500000, guid: 52f87dd051395614ebf0004d18d43bba, type: 3}
|
|
||||||
m_Name:
|
|
||||||
m_EditorClassIdentifier:
|
|
||||||
raycast: {fileID: 9178730298827149128}
|
|
||||||
firePoint: {fileID: 6083229256174510991}
|
|
||||||
projectilePrefab: {fileID: 198792769130808804, guid: 4543ab5e3d405ec40a8d4e9aa5165030,
|
|
||||||
type: 3}
|
|
||||||
audioSource: {fileID: 0}
|
|
||||||
--- !u!114 &8568640505362233545
|
--- !u!114 &8568640505362233545
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -1562,10 +1545,9 @@ MonoBehaviour:
|
|||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
targetTransform: {fileID: 2528273238195566709}
|
targetTransform: {fileID: 2528273238195566709}
|
||||||
cameraTransform: {fileID: 3401070369230030472}
|
cameraTransform: {fileID: 3401070369230030472}
|
||||||
lookSpeed: 0.1
|
lookSpeed: 0.7
|
||||||
followSpeed: 0.1
|
followSpeed: 0.1
|
||||||
pivotSpeed: 0.03
|
pivotSpeed: 0.03
|
||||||
LookAngle: 0
|
|
||||||
minimumPivot: -35
|
minimumPivot: -35
|
||||||
maximumPivot: 35
|
maximumPivot: 35
|
||||||
--- !u!114 &5876264296742387244
|
--- !u!114 &5876264296742387244
|
||||||
@ -1676,6 +1658,21 @@ AudioSource:
|
|||||||
m_PreInfinity: 2
|
m_PreInfinity: 2
|
||||||
m_PostInfinity: 2
|
m_PostInfinity: 2
|
||||||
m_RotationOrder: 4
|
m_RotationOrder: 4
|
||||||
|
--- !u!114 &1774200722056680610
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 2528273238195332181}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 52f87dd051395614ebf0004d18d43bba, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
firePoint: {fileID: 6083229256174510991}
|
||||||
|
projectilePrefab: {fileID: 198792769130808804, guid: 4543ab5e3d405ec40a8d4e9aa5165030,
|
||||||
|
type: 3}
|
||||||
--- !u!1 &2528273238195332183
|
--- !u!1 &2528273238195332183
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -3405,7 +3402,7 @@ Transform:
|
|||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_GameObject: {fileID: 6083229256174510991}
|
m_GameObject: {fileID: 6083229256174510991}
|
||||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
m_LocalPosition: {x: 0.373, y: 1.327, z: 1.105}
|
m_LocalPosition: {x: 0.373, y: 1.327, z: 1.4}
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
m_Children:
|
m_Children:
|
||||||
- {fileID: 2528273238195566651}
|
- {fileID: 2528273238195566651}
|
||||||
|
@ -74,8 +74,8 @@ namespace Animators.Leonid_Animator
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
anim.SetFloat(_horizontal, horizontal, 0.1f, Time.deltaTime);
|
anim.SetFloat(_horizontal, horizontal, 0.1f, Time.unscaledDeltaTime);
|
||||||
anim.SetFloat(_vertical, vertical, 0.1f, Time.deltaTime);
|
anim.SetFloat(_vertical, vertical, 0.1f, Time.unscaledDeltaTime);
|
||||||
|
|
||||||
if (pressedCrouching == true)
|
if (pressedCrouching == true)
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using System;
|
using UnityEngine;
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
namespace Animators.Leonid_Animator.Player
|
namespace Animators.Leonid_Animator.Player
|
||||||
{
|
{
|
||||||
@ -40,7 +39,7 @@ namespace Animators.Leonid_Animator.Player
|
|||||||
|
|
||||||
private void Update()
|
private void Update()
|
||||||
{
|
{
|
||||||
var deltaTime = Time.deltaTime;
|
var deltaTime = Time.unscaledDeltaTime;
|
||||||
_inputHandler.TickInput(deltaTime);
|
_inputHandler.TickInput(deltaTime);
|
||||||
_moveDirection = _cameraObject.forward * _inputHandler.vertical
|
_moveDirection = _cameraObject.forward * _inputHandler.vertical
|
||||||
+ _cameraObject.right * _inputHandler.horizontal;
|
+ _cameraObject.right * _inputHandler.horizontal;
|
||||||
@ -66,7 +65,7 @@ namespace Animators.Leonid_Animator.Player
|
|||||||
var velocity = myRigidbody.velocity;
|
var velocity = myRigidbody.velocity;
|
||||||
myRigidbody.AddForce(_inputHandler.jumpPressed ?
|
myRigidbody.AddForce(_inputHandler.jumpPressed ?
|
||||||
new Vector3(0, jumpForce, 0)
|
new Vector3(0, jumpForce, 0)
|
||||||
: new Vector3(velocity.x*100, -50, velocity.z * 100));
|
: new Vector3(velocity.x*200, -50, velocity.z * 200));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LateUpdate()
|
private void LateUpdate()
|
||||||
@ -95,7 +94,6 @@ namespace Animators.Leonid_Animator.Player
|
|||||||
if (Mathf.Abs(_inputHandler.horizontal) + Mathf.Abs(_inputHandler.vertical) < 0.1)
|
if (Mathf.Abs(_inputHandler.horizontal) + Mathf.Abs(_inputHandler.vertical) < 0.1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var moveAmount = _inputHandler.moveAmount;
|
|
||||||
var targetDir = _cameraObject.forward * _inputHandler.vertical
|
var targetDir = _cameraObject.forward * _inputHandler.vertical
|
||||||
+ _cameraObject.right * _inputHandler.horizontal;
|
+ _cameraObject.right * _inputHandler.horizontal;
|
||||||
targetDir.Normalize();
|
targetDir.Normalize();
|
||||||
@ -103,8 +101,6 @@ namespace Animators.Leonid_Animator.Player
|
|||||||
if (targetDir == Vector3.zero)
|
if (targetDir == Vector3.zero)
|
||||||
targetDir = myTransform.forward;
|
targetDir = myTransform.forward;
|
||||||
|
|
||||||
var rotSpeed = rotationSpeed;
|
|
||||||
|
|
||||||
var rotation = Quaternion.LookRotation(targetDir);
|
var rotation = Quaternion.LookRotation(targetDir);
|
||||||
var targetRotation = Quaternion.Slerp(myTransform.rotation, rotation, rotationSpeed * delta);
|
var targetRotation = Quaternion.Slerp(myTransform.rotation, rotation, rotationSpeed * delta);
|
||||||
myTransform.rotation = targetRotation;
|
myTransform.rotation = targetRotation;
|
||||||
|
@ -31,8 +31,8 @@ namespace Animators.Leonid_Animator.Player
|
|||||||
|
|
||||||
private void Update()
|
private void Update()
|
||||||
{
|
{
|
||||||
_cameraHandler.TargetPosition(Time.deltaTime);
|
_cameraHandler.TargetPosition(Time.unscaledDeltaTime);
|
||||||
_cameraHandler.HandleCameraRotation(Time.deltaTime, mouseX, mouseY);
|
_cameraHandler.HandleCameraRotation(Time.unscaledDeltaTime, mouseX, mouseY);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnEnable()
|
private void OnEnable()
|
||||||
@ -48,7 +48,7 @@ namespace Animators.Leonid_Animator.Player
|
|||||||
context => crouchPressed = true;
|
context => crouchPressed = true;
|
||||||
_inputActions.PlayerActions.Jump.performed +=
|
_inputActions.PlayerActions.Jump.performed +=
|
||||||
context => jumpPressed = true;
|
context => jumpPressed = true;
|
||||||
_inputActions.PlayerActions.Fire.performed +=
|
_inputActions.PlayerActions.Fire.started +=
|
||||||
context => firePressed = true;
|
context => firePressed = true;
|
||||||
_inputActions.PlayerActions.Fire.canceled +=
|
_inputActions.PlayerActions.Fire.canceled +=
|
||||||
context => firePressed = false;
|
context => firePressed = false;
|
||||||
|
@ -68,7 +68,9 @@ public class CharacterFactory : MonoBehaviour
|
|||||||
if (typeAi == TypeAI.HumanAI)
|
if (typeAi == TypeAI.HumanAI)
|
||||||
{
|
{
|
||||||
print("added player to list");
|
print("added player to list");
|
||||||
gameobject.GetComponent<Player>().GetCharacter.Team = team;
|
var myPlayer = gameobject.GetComponent<Player>().GetCharacter;
|
||||||
|
myPlayer.Team = team;
|
||||||
|
myPlayer.TypeAi = TypeAI.HumanAI;
|
||||||
Player = gameobject;
|
Player = gameobject;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
using System;
|
using Animators.Leonid_Animator;
|
||||||
using Animators.Leonid_Animator;
|
|
||||||
using Animators.Leonid_Animator.Player;
|
|
||||||
using Unity.Mathematics;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace CameraScripts
|
namespace CameraScripts
|
||||||
@ -14,11 +11,11 @@ namespace CameraScripts
|
|||||||
|
|
||||||
public static CameraHandler Singleton;
|
public static CameraHandler Singleton;
|
||||||
|
|
||||||
[SerializeField] private float lookSpeed = 0.1f;
|
[SerializeField] private float lookSpeed = 20f;
|
||||||
[SerializeField] private float followSpeed = 0.1f;
|
[SerializeField] private float followSpeed = 0.1f;
|
||||||
[SerializeField] private float pivotSpeed = 0.03f;
|
[SerializeField] private float pivotSpeed = 0.03f;
|
||||||
|
|
||||||
public float LookAngle;
|
private float _lookAngle;
|
||||||
private float _pivotAngle;
|
private float _pivotAngle;
|
||||||
|
|
||||||
public float minimumPivot = -35;
|
public float minimumPivot = -35;
|
||||||
@ -48,12 +45,12 @@ namespace CameraScripts
|
|||||||
|
|
||||||
public void HandleCameraRotation(float delta, float mouseX, float mouseY)
|
public void HandleCameraRotation(float delta, float mouseX, float mouseY)
|
||||||
{
|
{
|
||||||
LookAngle += (mouseX * lookSpeed) / delta;
|
_lookAngle += (mouseX * lookSpeed) / delta;
|
||||||
_pivotAngle -= (mouseY * pivotSpeed) / delta;
|
_pivotAngle -= (mouseY * pivotSpeed) / delta;
|
||||||
_pivotAngle = Mathf.Clamp(_pivotAngle, minimumPivot, maximumPivot);
|
_pivotAngle = Mathf.Clamp(_pivotAngle, minimumPivot, maximumPivot);
|
||||||
|
|
||||||
var rotation = Vector3.zero;
|
var rotation = Vector3.zero;
|
||||||
rotation.y = LookAngle;
|
rotation.y = _lookAngle;
|
||||||
transform.rotation = Quaternion.Euler(rotation);
|
transform.rotation = Quaternion.Euler(rotation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,47 +0,0 @@
|
|||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
public class CameraMouseScript : MonoBehaviour
|
|
||||||
{
|
|
||||||
public float moveSpeed;
|
|
||||||
public float shiftAdditionalSpeed;
|
|
||||||
public float mouseSensitivity;
|
|
||||||
public bool invertMouse;
|
|
||||||
public bool autoLockCursor;
|
|
||||||
|
|
||||||
public Camera cam;
|
|
||||||
|
|
||||||
public GameObject character;
|
|
||||||
|
|
||||||
void Awake()
|
|
||||||
{
|
|
||||||
cam = this.gameObject.GetComponent<Camera>();
|
|
||||||
this.gameObject.name = "SpectatorCamera";
|
|
||||||
Cursor.lockState = (autoLockCursor) ? CursorLockMode.Locked : CursorLockMode.None;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Update () {
|
|
||||||
if (character.transform.rotation.x < 15 && character.transform.rotation.x > -15)
|
|
||||||
{
|
|
||||||
float speed = (moveSpeed + (Input.GetAxis("Fire3") * shiftAdditionalSpeed));
|
|
||||||
this.gameObject.transform.Translate(Vector3.forward * speed * Input.GetAxis("Vertical"));
|
|
||||||
this.gameObject.transform.Translate(Vector3.right * speed * Input.GetAxis("Horizontal"));
|
|
||||||
this.gameObject.transform.Translate(Vector3.up * speed *
|
|
||||||
(Input.GetAxis("Jump") + (Input.GetAxis("Fire1") * -1)));
|
|
||||||
this.gameObject.transform.Rotate(Input.GetAxis("Mouse Y") * mouseSensitivity * ((invertMouse) ? 1 : -1),
|
|
||||||
Input.GetAxis("Mouse X") * mouseSensitivity * ((invertMouse) ? -1 : 1), 0);
|
|
||||||
this.gameObject.transform.localEulerAngles = new Vector3(this.gameObject.transform.localEulerAngles.x,
|
|
||||||
this.gameObject.transform.localEulerAngles.y, 0);
|
|
||||||
|
|
||||||
if (Cursor.lockState == CursorLockMode.None && Input.GetMouseButtonDown(0))
|
|
||||||
{
|
|
||||||
Cursor.lockState = CursorLockMode.Locked;
|
|
||||||
}
|
|
||||||
else if (Cursor.lockState == CursorLockMode.Locked && Input.GetKeyDown(KeyCode.Escape))
|
|
||||||
{
|
|
||||||
Cursor.lockState = CursorLockMode.None;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
11
Assets/Scripts/Character/CameraMouseScript.cs.meta
generated
11
Assets/Scripts/Character/CameraMouseScript.cs.meta
generated
@ -1,11 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: e63e19e155f6b6348897150b67863072
|
|
||||||
MonoImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences: []
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
@ -26,7 +26,6 @@ public class Player : MonoBehaviour, ICharacter
|
|||||||
PlayerCharacter.LastTimeHit = TimeManager.Instance.CurrentTime;
|
PlayerCharacter.LastTimeHit = TimeManager.Instance.CurrentTime;
|
||||||
Condition.GiveHealth(-Mathf.RoundToInt(damage * (1 - Condition.ArmourPoints * 0.5f)));
|
Condition.GiveHealth(-Mathf.RoundToInt(damage * (1 - Condition.ArmourPoints * 0.5f)));
|
||||||
Condition.GiveArmour(-Mathf.RoundToInt(Mathf.Sqrt(damage) * 5));
|
Condition.GiveArmour(-Mathf.RoundToInt(Mathf.Sqrt(damage) * 5));
|
||||||
print(Condition.HealthPoints);
|
|
||||||
if (Condition.HealthPoints < 10)
|
if (Condition.HealthPoints < 10)
|
||||||
Die();
|
Die();
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,6 @@ public class FlagZone : MonoBehaviour
|
|||||||
}
|
}
|
||||||
else if (occupAttackers > 0)
|
else if (occupAttackers > 0)
|
||||||
{
|
{
|
||||||
print("Atackers ocuppy flag");
|
|
||||||
TimeStayAttackers += Time.deltaTime;
|
TimeStayAttackers += Time.deltaTime;
|
||||||
GameManager._attackersTeam.AddGroupReward(Time.deltaTime* 0.1f);
|
GameManager._attackersTeam.AddGroupReward(Time.deltaTime* 0.1f);
|
||||||
GameManager._defendersTeam.AddGroupReward(-Time.deltaTime* 0.1f);
|
GameManager._defendersTeam.AddGroupReward(-Time.deltaTime* 0.1f);
|
||||||
@ -68,7 +67,6 @@ public class FlagZone : MonoBehaviour
|
|||||||
}
|
}
|
||||||
else if (occupDefenders > 0)
|
else if (occupDefenders > 0)
|
||||||
{
|
{
|
||||||
print("Defenders ocuppy flag");
|
|
||||||
GameManager._defendersTeam.AddGroupReward(+Time.deltaTime* 0.1f);
|
GameManager._defendersTeam.AddGroupReward(+Time.deltaTime* 0.1f);
|
||||||
TimeStayDefenders += Time.deltaTime;
|
TimeStayDefenders += Time.deltaTime;
|
||||||
if (TimeStayDefenders > timeForWin)
|
if (TimeStayDefenders > timeForWin)
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
using System.Collections;
|
using System.Collections;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using Weapons;
|
||||||
|
|
||||||
[RequireComponent(typeof(NPC))]
|
[RequireComponent(typeof(NPC))]
|
||||||
public class AimAssistant : MonoBehaviour
|
public class AimAssistant : MonoBehaviour
|
||||||
{
|
{
|
||||||
[HideInInspector] public GameObject enemy;
|
[HideInInspector] public GameObject enemy;
|
||||||
private Shooting _shooting;
|
private BotShooter _botShooter;
|
||||||
public bool isFiring = false;
|
public bool isFiring = false;
|
||||||
private NPC _myNpc;
|
private NPC _myNpc;
|
||||||
[SerializeField] private float lookSpeed = 400f;
|
[SerializeField] private float lookSpeed = 400f;
|
||||||
@ -19,14 +20,13 @@ public class AimAssistant : MonoBehaviour
|
|||||||
private void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
_myNpc = GetComponent<NPC>();
|
_myNpc = GetComponent<NPC>();
|
||||||
_shooting = GetComponent<Shooting>();
|
_botShooter = GetComponent<BotShooter>();
|
||||||
_myTransform = transform;
|
_myTransform = transform;
|
||||||
_fireCountdown = 1f / SettingsReader.Instance.GetSettings.RateOfFire;
|
_fireCountdown = 1f / SettingsReader.Instance.GetSettings.RateOfFire;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void FixedUpdate()
|
private void FixedUpdate()
|
||||||
{
|
{
|
||||||
//Ищем противника на сцене.
|
|
||||||
if (isFiring == false)
|
if (isFiring == false)
|
||||||
{
|
{
|
||||||
var enemies = GameManager.GetVisibleEnemies(_myNpc.GetCharacter.Team.GetOppositeTeam(), transform.position);
|
var enemies = GameManager.GetVisibleEnemies(_myNpc.GetCharacter.Team.GetOppositeTeam(), transform.position);
|
||||||
@ -72,6 +72,7 @@ public class AimAssistant : MonoBehaviour
|
|||||||
if (enemy != null)
|
if (enemy != null)
|
||||||
{
|
{
|
||||||
var direction = enemy.transform.position - gameObject.transform.position;
|
var direction = enemy.transform.position - gameObject.transform.position;
|
||||||
|
if (direction == Vector3.zero) return;
|
||||||
var targetRotation = Quaternion.LookRotation(direction);
|
var targetRotation = Quaternion.LookRotation(direction);
|
||||||
var lookAt = Quaternion.RotateTowards(gameObject.transform.rotation, targetRotation,
|
var lookAt = Quaternion.RotateTowards(gameObject.transform.rotation, targetRotation,
|
||||||
Time.deltaTime * lookSpeed);
|
Time.deltaTime * lookSpeed);
|
||||||
@ -92,8 +93,9 @@ public class AimAssistant : MonoBehaviour
|
|||||||
{
|
{
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
_shooting.BotShoot();
|
_botShooter.BotShoot();
|
||||||
yield return new WaitForSeconds(_fireCountdown);
|
yield return new WaitForSeconds(_fireCountdown);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
50
Assets/Scripts/Weapons/BotShooter.cs
Normal file
50
Assets/Scripts/Weapons/BotShooter.cs
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace Weapons
|
||||||
|
{
|
||||||
|
public class BotShooter : MonoBehaviour
|
||||||
|
{
|
||||||
|
[SerializeField] private GameObject firePoint;
|
||||||
|
[SerializeField] private ParticleSystem projectilePrefab;
|
||||||
|
private NPC _myNpc;
|
||||||
|
private MovementController _moveCtrl;
|
||||||
|
private AudioSource _audioSource;
|
||||||
|
|
||||||
|
private void Awake()
|
||||||
|
{
|
||||||
|
_myNpc = GetComponent<NPC>();
|
||||||
|
_moveCtrl = GetComponent<MovementController>();
|
||||||
|
_audioSource = GetComponent<AudioSource>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void BotShoot()
|
||||||
|
{
|
||||||
|
if (Physics.Raycast(firePoint.transform.position,
|
||||||
|
firePoint.transform.forward, out var hit,
|
||||||
|
SettingsReader.Instance.GetSettings.ViewDistance))
|
||||||
|
{
|
||||||
|
if (hit.transform.TryGetComponent<ICharacter>(out var target))
|
||||||
|
{
|
||||||
|
print($"did damage to {hit.transform.name}");
|
||||||
|
_audioSource.Play();
|
||||||
|
Instantiate(projectilePrefab, firePoint.transform.position, firePoint.transform.rotation);
|
||||||
|
var mySpeed = _moveCtrl.Velocity.magnitude;
|
||||||
|
var enemySpeed = 0f;
|
||||||
|
var inCover = false;
|
||||||
|
if (target.GetCharacter.TypeAi == TypeAI.HumanAI)
|
||||||
|
enemySpeed = hit.rigidbody.velocity.magnitude;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
enemySpeed = hit.collider.GetComponent<MovementController>().Velocity.magnitude;
|
||||||
|
inCover = hit.collider.GetComponent<NPC>().NpcState.InCover;
|
||||||
|
}
|
||||||
|
|
||||||
|
var hitChance = (1 - 0.5 * mySpeed) * (1 - 0.5 * enemySpeed + 0.5*inCover.ToInt()) / 1.5f;
|
||||||
|
if (!(Random.Range(0f, 1f) < hitChance)) return;
|
||||||
|
_myNpc.AddReward(0.05f);
|
||||||
|
target.GetDamage(SettingsReader.Instance.GetSettings.RifleDamage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
3
Assets/Scripts/Weapons/BotShooter.cs.meta
generated
Normal file
3
Assets/Scripts/Weapons/BotShooter.cs.meta
generated
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 2a6ce8ea5e584f40922a36bdb4219494
|
||||||
|
timeCreated: 1652982070
|
57
Assets/Scripts/Weapons/PlayerShooter.cs
Normal file
57
Assets/Scripts/Weapons/PlayerShooter.cs
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
using Animators.Leonid_Animator.Player;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace Weapons
|
||||||
|
{
|
||||||
|
[RequireComponent(typeof(AudioSource))]
|
||||||
|
[RequireComponent(typeof(InputHandler))]
|
||||||
|
public class PlayerShooter : MonoBehaviour
|
||||||
|
{
|
||||||
|
public GameObject firePoint;
|
||||||
|
|
||||||
|
public ParticleSystem projectilePrefab;
|
||||||
|
|
||||||
|
private float _fireCountdown = 0.5f;
|
||||||
|
|
||||||
|
private AudioSource _audioSource;
|
||||||
|
private InputHandler _inputHandler;
|
||||||
|
|
||||||
|
private void Awake()
|
||||||
|
{
|
||||||
|
_audioSource = GetComponent<AudioSource>();
|
||||||
|
_inputHandler = GetComponent<InputHandler>();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Update()
|
||||||
|
{
|
||||||
|
HandleMouseButton();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void HandleMouseButton()
|
||||||
|
{
|
||||||
|
if (_inputHandler.firePressed && _fireCountdown <= 0f)
|
||||||
|
{
|
||||||
|
_fireCountdown = 0.5f;
|
||||||
|
PlayerShoot();
|
||||||
|
}
|
||||||
|
|
||||||
|
_fireCountdown -= Time.unscaledDeltaTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void PlayerShoot()
|
||||||
|
{
|
||||||
|
_audioSource.Play();
|
||||||
|
Instantiate(projectilePrefab, firePoint.transform.position, firePoint.transform.rotation);
|
||||||
|
if (Physics.Raycast(firePoint.transform.position,
|
||||||
|
firePoint.transform.forward, out var hit,
|
||||||
|
SettingsReader.Instance.GetSettings.ViewDistance))
|
||||||
|
{
|
||||||
|
if (hit.transform.TryGetComponent<NPC>(out var target))
|
||||||
|
{
|
||||||
|
print($"did damage to {hit.transform.name}");
|
||||||
|
target.GetDamage(SettingsReader.Instance.GetSettings.RifleDamage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,90 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using JetBrains.Annotations;
|
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
[RequireComponent(typeof(AudioSource))]
|
|
||||||
public class Shooting : MonoBehaviour
|
|
||||||
{
|
|
||||||
public GameObject raycast;
|
|
||||||
|
|
||||||
public GameObject firePoint;
|
|
||||||
|
|
||||||
public ParticleSystem projectilePrefab;
|
|
||||||
|
|
||||||
private float hSliderValue = 0.1f;
|
|
||||||
private float _fireCountdown = 0.1f;
|
|
||||||
|
|
||||||
public AudioSource audioSource;
|
|
||||||
private NPC _myNpc;
|
|
||||||
private MovementController _moveCtrl;
|
|
||||||
|
|
||||||
private void Awake()
|
|
||||||
{
|
|
||||||
audioSource = GetComponent<AudioSource>();
|
|
||||||
TryGetComponent(out _moveCtrl);
|
|
||||||
TryGetComponent(out _myNpc);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Update()
|
|
||||||
{
|
|
||||||
HandleMouseButton();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void HandleMouseButton()
|
|
||||||
{
|
|
||||||
if (Input.GetMouseButton(0) && _fireCountdown <= 0f)
|
|
||||||
{
|
|
||||||
_fireCountdown = 0;
|
|
||||||
_fireCountdown += hSliderValue;
|
|
||||||
PlayerShoot();
|
|
||||||
}
|
|
||||||
|
|
||||||
_fireCountdown -= Time.deltaTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void PlayerShoot()
|
|
||||||
{
|
|
||||||
audioSource.Play();
|
|
||||||
Instantiate(projectilePrefab, firePoint.transform.position, firePoint.transform.rotation);
|
|
||||||
if (Physics.Raycast(raycast.transform.position,
|
|
||||||
raycast.transform.forward, out var hit,
|
|
||||||
SettingsReader.Instance.GetSettings.ViewDistance))
|
|
||||||
{
|
|
||||||
if (hit.transform.TryGetComponent<NPC>(out var target))
|
|
||||||
{
|
|
||||||
target.GetDamage(SettingsReader.Instance.GetSettings.RifleDamage);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void BotShoot()
|
|
||||||
{
|
|
||||||
if (Physics.Raycast(raycast.transform.position,
|
|
||||||
raycast.transform.forward, out var hit,
|
|
||||||
SettingsReader.Instance.GetSettings.ViewDistance))
|
|
||||||
{
|
|
||||||
if (hit.transform.TryGetComponent<ICharacter>(out var target))
|
|
||||||
{
|
|
||||||
audioSource.Play();
|
|
||||||
Instantiate(projectilePrefab, firePoint.transform.position, firePoint.transform.rotation);
|
|
||||||
var mySpeed = _moveCtrl.Velocity.magnitude;
|
|
||||||
var enemySpeed = 0f;
|
|
||||||
var inCover = false;
|
|
||||||
if (target.GetCharacter.TypeAi == TypeAI.HumanAI)
|
|
||||||
enemySpeed = hit.rigidbody.velocity.magnitude;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
enemySpeed = hit.collider.GetComponent<MovementController>().Velocity.magnitude;
|
|
||||||
inCover = hit.collider.GetComponent<NPC>().NpcState.InCover;
|
|
||||||
}
|
|
||||||
|
|
||||||
var hitChance = (1 - 0.5 * mySpeed) * (1 - 0.5 * enemySpeed + 0.5*inCover.ToInt()) / 1.5f;
|
|
||||||
if (!(UnityEngine.Random.Range(0f, 1f) < hitChance)) return;
|
|
||||||
_myNpc.AddReward(0.05f);
|
|
||||||
target.GetDamage(SettingsReader.Instance.GetSettings.RifleDamage);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
2
Assets/Settings/Game Settings.asset
generated
2
Assets/Settings/Game Settings.asset
generated
@ -21,7 +21,7 @@ MonoBehaviour:
|
|||||||
AtcTeamAI: 3
|
AtcTeamAI: 3
|
||||||
NumOfDefenders: 3
|
NumOfDefenders: 3
|
||||||
NumOfAttackers: 3
|
NumOfAttackers: 3
|
||||||
HasHumanDefender: 0
|
HasHumanDefender: 1
|
||||||
HasHumanAttacker: 0
|
HasHumanAttacker: 0
|
||||||
HealthPickupAmount: 50
|
HealthPickupAmount: 50
|
||||||
ArmourPickupAmount: 50
|
ArmourPickupAmount: 50
|
||||||
|
Reference in New Issue
Block a user