This commit is contained in:
Norbi Peti 2020-12-08 10:14:32 +01:00
parent 78d1d5419c
commit 6f61c8a7c4
No known key found for this signature in database
GPG key ID: DBA4C4549A927E56
3 changed files with 21 additions and 18 deletions

View file

@ -1,3 +1,4 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
@ -51,6 +52,11 @@ public class EnemyAI : MonoBehaviour
// Start a new path to the target position, return the result to the OnPathComplete method
_seeker.StartPath(transform.position, _target.position, OnPathComplete);
//StartCoroutine(UpdatePath());
}
private void OnEnable()
{
StartCoroutine(UpdatePath());
}
@ -99,15 +105,12 @@ public class EnemyAI : MonoBehaviour
Vector3 dir = (_path.vectorPath[_currentWaypoint] - transform.position).normalized;
dir *= speed * Time.fixedDeltaTime;
//if(Vector3.Distance (transform.position, _target.position) < 10)
//{
float diff = Vector3.Distance(transform.position, _target.position);
//Move the AI
//_rb.AddForce(dir, fMode);
_rb.velocity = dir;
//}
_rb.AddForce(dir * 10 / diff, fMode);
if (_path.vectorPath[_currentWaypoint].y - transform.position.y > 1)
_rb.AddForce(new Vector2(0, 10f));
_rb.AddForce(new Vector2(0, 20f));
float dist = Vector3.Distance(transform.position, _path.vectorPath[_currentWaypoint]);
if (dist < nextWaypointDistance)

View file

@ -20,7 +20,7 @@ public class NavMeshUpdater : MonoBehaviour
private void Update()
{
if (Mathf.Abs(player.position.x - _gg.center.x) > _gg.width / 4f)
if (Mathf.Abs(player.position.x - _gg.center.x) > _gg.width * _gg.nodeSize / 4f)
{
var pos = _gg.center;
pos.x = player.position.x;

View file

@ -1,34 +1,30 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Assembly-CSharp", "Assembly-CSharp.csproj", "{78B42BEC-C559-63E3-6996-7DE1ABC1B6B0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AstarPathfindingProject", "AstarPathfindingProject.csproj", "{5CCEE858-6C72-CBFD-AB4D-C14A74568B2C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Assembly-CSharp-Editor", "Assembly-CSharp-Editor.csproj", "{FDE76E55-8F95-B17A-F5EB-F218F1B07F99}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Assembly-CSharp", "Assembly-CSharp.csproj", "{78B42BEC-C559-63E3-6996-7DE1ABC1B6B0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AstarPathfindingProjectEditor", "AstarPathfindingProjectEditor.csproj", "{D490F06A-6B5E-2FC6-4BC7-5DE43DB4B967}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PackageToolsEditor", "PackageToolsEditor.csproj", "{F32E2685-1CA3-72C0-A278-83F3E677A98E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Assembly-CSharp-Editor", "Assembly-CSharp-Editor.csproj", "{FDE76E55-8F95-B17A-F5EB-F218F1B07F99}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{78B42BEC-C559-63E3-6996-7DE1ABC1B6B0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{78B42BEC-C559-63E3-6996-7DE1ABC1B6B0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{78B42BEC-C559-63E3-6996-7DE1ABC1B6B0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{78B42BEC-C559-63E3-6996-7DE1ABC1B6B0}.Release|Any CPU.Build.0 = Release|Any CPU
{5CCEE858-6C72-CBFD-AB4D-C14A74568B2C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5CCEE858-6C72-CBFD-AB4D-C14A74568B2C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5CCEE858-6C72-CBFD-AB4D-C14A74568B2C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5CCEE858-6C72-CBFD-AB4D-C14A74568B2C}.Release|Any CPU.Build.0 = Release|Any CPU
{FDE76E55-8F95-B17A-F5EB-F218F1B07F99}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FDE76E55-8F95-B17A-F5EB-F218F1B07F99}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FDE76E55-8F95-B17A-F5EB-F218F1B07F99}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FDE76E55-8F95-B17A-F5EB-F218F1B07F99}.Release|Any CPU.Build.0 = Release|Any CPU
{78B42BEC-C559-63E3-6996-7DE1ABC1B6B0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{78B42BEC-C559-63E3-6996-7DE1ABC1B6B0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{78B42BEC-C559-63E3-6996-7DE1ABC1B6B0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{78B42BEC-C559-63E3-6996-7DE1ABC1B6B0}.Release|Any CPU.Build.0 = Release|Any CPU
{D490F06A-6B5E-2FC6-4BC7-5DE43DB4B967}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D490F06A-6B5E-2FC6-4BC7-5DE43DB4B967}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D490F06A-6B5E-2FC6-4BC7-5DE43DB4B967}.Release|Any CPU.ActiveCfg = Release|Any CPU
@ -37,6 +33,10 @@ Global
{F32E2685-1CA3-72C0-A278-83F3E677A98E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F32E2685-1CA3-72C0-A278-83F3E677A98E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F32E2685-1CA3-72C0-A278-83F3E677A98E}.Release|Any CPU.Build.0 = Release|Any CPU
{FDE76E55-8F95-B17A-F5EB-F218F1B07F99}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FDE76E55-8F95-B17A-F5EB-F218F1B07F99}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FDE76E55-8F95-B17A-F5EB-F218F1B07F99}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FDE76E55-8F95-B17A-F5EB-F218F1B07F99}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE