Unit movement
This commit is contained in:
parent
378d3001a3
commit
6dc8944e63
|
@ -1,117 +0,0 @@
|
||||||
%YAML 1.1
|
|
||||||
%TAG !u! tag:unity3d.com,2011:
|
|
||||||
--- !u!1 &1856962702766056601
|
|
||||||
GameObject:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
serializedVersion: 6
|
|
||||||
m_Component:
|
|
||||||
- component: {fileID: 5214357893675647508}
|
|
||||||
- component: {fileID: 1383158180383209498}
|
|
||||||
- component: {fileID: 5323256792100004051}
|
|
||||||
- component: {fileID: 2403604765386540949}
|
|
||||||
m_Layer: 0
|
|
||||||
m_Name: NetworkManager
|
|
||||||
m_TagString: Untagged
|
|
||||||
m_Icon: {fileID: 0}
|
|
||||||
m_NavMeshLayer: 0
|
|
||||||
m_StaticEditorFlags: 0
|
|
||||||
m_IsActive: 1
|
|
||||||
--- !u!4 &5214357893675647508
|
|
||||||
Transform:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 1856962702766056601}
|
|
||||||
serializedVersion: 2
|
|
||||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
|
||||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
|
||||||
m_ConstrainProportionsScale: 0
|
|
||||||
m_Children: []
|
|
||||||
m_Father: {fileID: 0}
|
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
|
||||||
--- !u!114 &1383158180383209498
|
|
||||||
MonoBehaviour:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 1856962702766056601}
|
|
||||||
m_Enabled: 1
|
|
||||||
m_EditorHideFlags: 0
|
|
||||||
m_Script: {fileID: 11500000, guid: 3576b25916b37ae4a9d41dda8c36f224, type: 3}
|
|
||||||
m_Name:
|
|
||||||
m_EditorClassIdentifier:
|
|
||||||
dontDestroyOnLoad: 1
|
|
||||||
runInBackground: 1
|
|
||||||
autoStartServerBuild: 1
|
|
||||||
autoConnectClientBuild: 0
|
|
||||||
sendRate: 60
|
|
||||||
offlineScene:
|
|
||||||
onlineScene:
|
|
||||||
transport: {fileID: 2403604765386540949}
|
|
||||||
networkAddress: localhost
|
|
||||||
maxConnections: 100
|
|
||||||
disconnectInactiveConnections: 0
|
|
||||||
disconnectInactiveTimeout: 60
|
|
||||||
authenticator: {fileID: 0}
|
|
||||||
playerPrefab: {fileID: 5181188659209802552, guid: 137622a055406ed4f823d72e0ad2fd8a,
|
|
||||||
type: 3}
|
|
||||||
autoCreatePlayer: 1
|
|
||||||
playerSpawnMethod: 1
|
|
||||||
spawnPrefabs: []
|
|
||||||
snapshotSettings:
|
|
||||||
bufferTimeMultiplier: 2
|
|
||||||
bufferLimit: 32
|
|
||||||
catchupNegativeThreshold: -1
|
|
||||||
catchupPositiveThreshold: 1
|
|
||||||
catchupSpeed: 0.019999999552965164
|
|
||||||
slowdownSpeed: 0.03999999910593033
|
|
||||||
driftEmaDuration: 1
|
|
||||||
dynamicAdjustment: 1
|
|
||||||
dynamicAdjustmentTolerance: 1
|
|
||||||
deliveryTimeEmaDuration: 2
|
|
||||||
connectionQualityInterval: 3
|
|
||||||
timeInterpolationGui: 0
|
|
||||||
--- !u!114 &5323256792100004051
|
|
||||||
MonoBehaviour:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 1856962702766056601}
|
|
||||||
m_Enabled: 1
|
|
||||||
m_EditorHideFlags: 0
|
|
||||||
m_Script: {fileID: 11500000, guid: 6442dc8070ceb41f094e44de0bf87274, type: 3}
|
|
||||||
m_Name:
|
|
||||||
m_EditorClassIdentifier:
|
|
||||||
offsetX: 0
|
|
||||||
offsetY: 0
|
|
||||||
--- !u!114 &2403604765386540949
|
|
||||||
MonoBehaviour:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 1856962702766056601}
|
|
||||||
m_Enabled: 1
|
|
||||||
m_EditorHideFlags: 0
|
|
||||||
m_Script: {fileID: 11500000, guid: c7424c1070fad4ba2a7a96b02fbeb4bb, type: 3}
|
|
||||||
m_Name:
|
|
||||||
m_EditorClassIdentifier:
|
|
||||||
port: 7777
|
|
||||||
NoDelay: 1
|
|
||||||
SendTimeout: 5000
|
|
||||||
ReceiveTimeout: 30000
|
|
||||||
serverMaxMessageSize: 16384
|
|
||||||
serverMaxReceivesPerTick: 10000
|
|
||||||
serverSendQueueLimitPerConnection: 10000
|
|
||||||
serverReceiveQueueLimitPerConnection: 10000
|
|
||||||
clientMaxMessageSize: 16384
|
|
||||||
clientMaxReceivesPerTick: 1000
|
|
||||||
clientSendQueueLimit: 10000
|
|
||||||
clientReceiveQueueLimit: 10000
|
|
|
@ -10,6 +10,9 @@ GameObject:
|
||||||
m_Component:
|
m_Component:
|
||||||
- component: {fileID: 2385999535964237451}
|
- component: {fileID: 2385999535964237451}
|
||||||
- component: {fileID: 5351038950168726961}
|
- component: {fileID: 5351038950168726961}
|
||||||
|
- component: {fileID: 2439696136893951540}
|
||||||
|
- component: {fileID: 6123744421715133446}
|
||||||
|
- component: {fileID: 8681090027785358193}
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: Player
|
m_Name: Player
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
|
@ -50,6 +53,79 @@ MonoBehaviour:
|
||||||
serverOnly: 0
|
serverOnly: 0
|
||||||
visible: 0
|
visible: 0
|
||||||
hasSpawned: 0
|
hasSpawned: 0
|
||||||
|
--- !u!114 &2439696136893951540
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 5181188659209802552}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 8ff3ba0becae47b8b9381191598957c8, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
syncDirection: 0
|
||||||
|
syncMode: 0
|
||||||
|
syncInterval: 0
|
||||||
|
target: {fileID: 2385999535964237451}
|
||||||
|
clientAuthority: 0
|
||||||
|
syncPosition: 1
|
||||||
|
syncRotation: 1
|
||||||
|
syncScale: 0
|
||||||
|
interpolatePosition: 1
|
||||||
|
interpolateRotation: 1
|
||||||
|
interpolateScale: 1
|
||||||
|
coordinateSpace: 0
|
||||||
|
sendIntervalMultiplier: 1
|
||||||
|
timelineOffset: 0
|
||||||
|
showGizmos: 0
|
||||||
|
showOverlay: 0
|
||||||
|
overlayColor: {r: 0, g: 0, b: 0, a: 0.5}
|
||||||
|
onlySyncOnChange: 1
|
||||||
|
onlySyncOnChangeCorrectionMultiplier: 2
|
||||||
|
rotationSensitivity: 0.01
|
||||||
|
compressRotation: 0
|
||||||
|
positionPrecision: 0.01
|
||||||
|
scalePrecision: 0.01
|
||||||
|
--- !u!195 &6123744421715133446
|
||||||
|
NavMeshAgent:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 5181188659209802552}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_AgentTypeID: 1479372276
|
||||||
|
m_Radius: 2.13
|
||||||
|
m_Speed: 2.2
|
||||||
|
m_Acceleration: 2
|
||||||
|
avoidancePriority: 50
|
||||||
|
m_AngularSpeed: 90
|
||||||
|
m_StoppingDistance: 1
|
||||||
|
m_AutoTraverseOffMeshLink: 1
|
||||||
|
m_AutoBraking: 1
|
||||||
|
m_AutoRepath: 1
|
||||||
|
m_Height: 2.28
|
||||||
|
m_BaseOffset: 0
|
||||||
|
m_WalkableMask: 4294967295
|
||||||
|
m_ObstacleAvoidanceType: 4
|
||||||
|
--- !u!114 &8681090027785358193
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 5181188659209802552}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: dc5d69536d0782647a3de12f2d524c45, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
syncDirection: 0
|
||||||
|
syncMode: 0
|
||||||
|
syncInterval: 0
|
||||||
|
_navMeshAgent: {fileID: 6123744421715133446}
|
||||||
--- !u!1001 &4315183336175566048
|
--- !u!1001 &4315183336175566048
|
||||||
PrefabInstance:
|
PrefabInstance:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|
|
@ -539,7 +539,7 @@ MonoBehaviour:
|
||||||
m_Script: {fileID: 11500000, guid: 7a5ac11cc976e418e8d13136b07e1f52, type: 3}
|
m_Script: {fileID: 11500000, guid: 7a5ac11cc976e418e8d13136b07e1f52, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
m_AgentTypeID: 0
|
m_AgentTypeID: 1479372276
|
||||||
m_CollectObjects: 0
|
m_CollectObjects: 0
|
||||||
m_Size: {x: 10, y: 10, z: 10}
|
m_Size: {x: 10, y: 10, z: 10}
|
||||||
m_Center: {x: 0, y: 2, z: 0}
|
m_Center: {x: 0, y: 2, z: 0}
|
||||||
|
@ -554,7 +554,7 @@ MonoBehaviour:
|
||||||
m_OverrideTileSize: 0
|
m_OverrideTileSize: 0
|
||||||
m_TileSize: 256
|
m_TileSize: 256
|
||||||
m_OverrideVoxelSize: 0
|
m_OverrideVoxelSize: 0
|
||||||
m_VoxelSize: 0.16666667
|
m_VoxelSize: 0.71000004
|
||||||
m_MinRegionArea: 2
|
m_MinRegionArea: 2
|
||||||
m_NavMeshData: {fileID: 23800000, guid: 484f98bbc6c0d2545ba1ca067ab3a2e2, type: 2}
|
m_NavMeshData: {fileID: 23800000, guid: 484f98bbc6c0d2545ba1ca067ab3a2e2, type: 2}
|
||||||
m_BuildHeightMesh: 0
|
m_BuildHeightMesh: 0
|
||||||
|
@ -768,7 +768,7 @@ Transform:
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
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: -0.5, z: 0}
|
m_LocalPosition: {x: 0, y: -0.5, z: 0}
|
||||||
m_LocalScale: {x: 20, y: 1, z: 20}
|
m_LocalScale: {x: 30, y: 1, z: 30}
|
||||||
m_ConstrainProportionsScale: 0
|
m_ConstrainProportionsScale: 0
|
||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 578241694}
|
m_Father: {fileID: 578241694}
|
||||||
|
|
Binary file not shown.
|
@ -1,7 +1,4 @@
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using Mirror;
|
using Mirror;
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
public class RtsNetworkManager : NetworkManager
|
public class RtsNetworkManager : NetworkManager
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: dce2bed696544cc42818b18b7e98f840
|
guid: 77bc0eda61472c04b807f23c440ef0bc
|
||||||
PrefabImporter:
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
userData:
|
userData:
|
||||||
assetBundleName:
|
assetBundleName:
|
|
@ -0,0 +1,48 @@
|
||||||
|
using Mirror;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.AI;
|
||||||
|
using UnityEngine.InputSystem;
|
||||||
|
|
||||||
|
public class UnitMovement : NetworkBehaviour
|
||||||
|
{
|
||||||
|
[SerializeField] private NavMeshAgent _navMeshAgent;
|
||||||
|
|
||||||
|
private Camera _camera;
|
||||||
|
private Mouse _mouse;
|
||||||
|
|
||||||
|
#region Server
|
||||||
|
|
||||||
|
[Command] private void CmdMove(Vector3 destination)
|
||||||
|
{
|
||||||
|
if (NavMesh.SamplePosition(destination, out NavMeshHit hit, 1f, NavMesh.AllAreas))
|
||||||
|
{
|
||||||
|
_navMeshAgent.SetDestination(hit.position);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Client
|
||||||
|
|
||||||
|
public override void OnStartAuthority()
|
||||||
|
{
|
||||||
|
base.OnStartAuthority();
|
||||||
|
_camera = Camera.main;
|
||||||
|
_mouse = Mouse.current;
|
||||||
|
}
|
||||||
|
|
||||||
|
[ClientCallback]
|
||||||
|
private void Update()
|
||||||
|
{
|
||||||
|
if (!isOwned) return;
|
||||||
|
if (!_mouse.rightButton.wasPressedThisFrame) return;
|
||||||
|
Ray ray = _camera.ScreenPointToRay(_mouse.position.ReadValue());
|
||||||
|
|
||||||
|
if (Physics.Raycast(ray, out RaycastHit hit, Mathf.Infinity))
|
||||||
|
{
|
||||||
|
CmdMove(hit.point);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: dc5d69536d0782647a3de12f2d524c45
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -127,10 +127,10 @@ NavMeshProjectSettings:
|
||||||
m_Flags: 0
|
m_Flags: 0
|
||||||
- serializedVersion: 3
|
- serializedVersion: 3
|
||||||
agentTypeID: 1479372276
|
agentTypeID: 1479372276
|
||||||
agentRadius: 0.5
|
agentRadius: 2.13
|
||||||
agentHeight: 2
|
agentHeight: 2.28
|
||||||
agentSlope: 45
|
agentSlope: 45
|
||||||
agentClimb: 0.4
|
agentClimb: 1.1
|
||||||
ledgeDropHeight: 0
|
ledgeDropHeight: 0
|
||||||
maxJumpAcrossDistance: 0
|
maxJumpAcrossDistance: 0
|
||||||
minRegionArea: 2
|
minRegionArea: 2
|
||||||
|
|
Loading…
Reference in New Issue