fix: correct teleport radius

This commit is contained in:
Bragin Stepan
2026-02-26 00:01:12 +05:00
parent 5f640ce72e
commit e4532ae3c2
9 changed files with 78 additions and 25 deletions

5
.vscode/settings.json vendored Normal file
View File

@@ -0,0 +1,5 @@
{
"dotrush.roslyn.projectOrSolutionFiles": [
"e:\\_Programming\\Unity\\UnityGames\\project-entity\\project-entity.sln"
]
}

View File

@@ -9,6 +9,7 @@ namespace _Project.Develop.Runtime.Logic.Gameplay.Features.Teleport.Systems
{
public class FindRandomPointForTeleportSystem : IInitializableSystem, IDisposableSystem
{
private Transform _target;
private Transform _toPoint;
private ReactiveEvent _findPointRequest;
@@ -20,6 +21,7 @@ namespace _Project.Develop.Runtime.Logic.Gameplay.Features.Teleport.Systems
public void OnInit(Entity entity)
{
_target = entity.TeleportTarget;
_toPoint = entity.TeleportToPoint;
_radius = entity.TeleportSearchRadius;
_findPointRequest = entity.FindTeleportPointRequest;
@@ -35,11 +37,14 @@ namespace _Project.Develop.Runtime.Logic.Gameplay.Features.Teleport.Systems
private void OnFindPointRequest()
{
_toPoint.position = GetRandomPointByRadius(_radius.Value);
_toPoint.position = GetRandomPointInRadius(_target.position, _radius.Value);
_findPointEvent.Invoke();
}
private Vector3 GetRandomPointByRadius(float radius)
=> new(Random.Range(0, radius), 0, Random.Range(0, radius));
private Vector3 GetRandomPointInRadius(Vector3 center, float radius)
{
Vector2 randomPoint = Random.insideUnitCircle * radius;
return center + new Vector3(randomPoint.x, 0f, randomPoint.y);
}
}
}

View File

@@ -1,10 +1,9 @@
{
"dependencies": {
"com.github-glitchenzo.nugetforunity": "https://github.com/GlitchEnzo/NuGetForUnity.git?path=/src/NuGetForUnity",
"com.unity.2d.sprite": "1.0.0",
"com.unity.collab-proxy": "2.8.2",
"com.unity.ide.rider": "3.0.27",
"com.unity.ide.visualstudio": "2.0.22",
"com.unity.ide.visualstudio": "2.0.27",
"com.unity.ide.vscode": "1.2.5",
"com.unity.inputsystem": "1.7.0",
"com.unity.render-pipelines.universal": "14.0.9",

View File

@@ -1,12 +1,5 @@
{
"dependencies": {
"com.github-glitchenzo.nugetforunity": {
"version": "https://github.com/GlitchEnzo/NuGetForUnity.git?path=/src/NuGetForUnity",
"depth": 0,
"source": "git",
"dependencies": {},
"hash": "c2af83c9d4f8cdaada9d4a0e94de2f195d8e1d01"
},
"com.unity.2d.sprite": {
"version": "1.0.0",
"depth": 0,
@@ -46,11 +39,11 @@
"url": "https://packages.unity.com"
},
"com.unity.ide.visualstudio": {
"version": "2.0.22",
"version": "2.0.27",
"depth": 0,
"source": "registry",
"dependencies": {
"com.unity.test-framework": "1.1.9"
"com.unity.test-framework": "1.1.33"
},
"url": "https://packages.unity.com"
},

View File

@@ -0,0 +1,17 @@
{
"MonoBehaviour": {
"Version": 4,
"EnableBurstCompilation": true,
"EnableOptimisations": true,
"EnableSafetyChecks": false,
"EnableDebugInAllBuilds": false,
"DebugDataKind": 1,
"EnableArmv9SecurityFeatures": false,
"CpuMinTargetX32": 0,
"CpuMaxTargetX32": 0,
"CpuMinTargetX64": 0,
"CpuMaxTargetX64": 0,
"CpuTargetsArm64": 512,
"OptimizeFor": 0
}
}

View File

@@ -1,16 +1,18 @@
{
"MonoBehaviour": {
"Version": 3,
"Version": 4,
"EnableBurstCompilation": true,
"EnableOptimisations": true,
"EnableSafetyChecks": false,
"EnableDebugInAllBuilds": false,
"UsePlatformSDKLinker": false,
"DebugDataKind": 0,
"EnableArmv9SecurityFeatures": false,
"CpuMinTargetX32": 0,
"CpuMaxTargetX32": 0,
"CpuMinTargetX64": 0,
"CpuMaxTargetX64": 0,
"CpuTargetsX32": 6,
"CpuTargetsX64": 72
"CpuTargetsX64": 72,
"OptimizeFor": 0
}
}

View File

@@ -0,0 +1,16 @@
{
"MonoBehaviour": {
"Version": 4,
"EnableBurstCompilation": true,
"EnableOptimisations": true,
"EnableSafetyChecks": false,
"EnableDebugInAllBuilds": false,
"DebugDataKind": 1,
"EnableArmv9SecurityFeatures": false,
"CpuMinTargetX32": 0,
"CpuMaxTargetX32": 0,
"CpuMinTargetX64": 0,
"CpuMaxTargetX64": 0,
"OptimizeFor": 0
}
}

View File

@@ -1,6 +1,6 @@
{
"MonoBehaviour": {
"Version": 3,
"Version": 4,
"DisabledWarnings": ""
}
}

View File

@@ -0,0 +1,16 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &1
MonoBehaviour:
m_ObjectHideFlags: 53
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: a287be6c49135cd4f9b2b8666c39d999, type: 3}
m_Name:
m_EditorClassIdentifier:
assetDefaultFramerate: 60
m_DefaultFrameRate: 60