1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
|
C++RAW
#include "UnityPrefix.h"
#include "Configuration/UnityConfigure.h"
#include "Runtime/Mono/MonoManager.h"
#include "Runtime/Mono/MonoBehaviour.h"
#include "Runtime/NavMesh/NavMesh.h"
#include "Runtime/NavMesh/NavMeshAgent.h"
#include "Runtime/NavMesh/OffMeshLink.h"
#include "Runtime/Scripting/ScriptingUtility.h"
#include "Runtime/Scripting/ScriptingExportUtility.h"
CSRAW
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace UnityEngine
{
// Keep this enum in sync with the one defined in "NavMeshTypes.h"
ENUM ObstacleAvoidanceType
// Disable avoidance.
NoObstacleAvoidance = 0,
// Enable simple avoidance. Low performance impact.
LowQualityObstacleAvoidance = 1,
// Medium avoidance. Medium performance impact
MedQualityObstacleAvoidance = 2,
// Good avoidance. High performance impact
GoodQualityObstacleAvoidance = 3,
// Enable highest precision. Highest performance impact.
HighQualityObstacleAvoidance = 4
END
// Navigation mesh agent.
CLASS NavMeshAgent : Behaviour
// Sets or updates the destination. This triggers calculation for a new path.
CUSTOM bool SetDestination (Vector3 target)
{
return self->SetDestination (target);
}
// Destination to navigate towards.
AUTO_PROP Vector3 destination GetDestination SetDestination
// Stop within this distance from the target position.
AUTO_PROP float stoppingDistance GetStoppingDistance SetStoppingDistance
// The current velocity of the [[NavMeshAgent]] component.
AUTO_PROP Vector3 velocity GetVelocity SetVelocity
// The next position on the path.
AUTO_PROP Vector3 nextPosition GetNextPosition SetInternalAgentPosition
// The current steering target - usually the next corner or end point of the current path. (RO)
AUTO_PROP Vector3 steeringTarget GetNextCorner
// The desired velocity of the agent including any potential contribution from avoidance. (RO)
AUTO_PROP Vector3 desiredVelocity GetDesiredVelocity
// Remaining distance along the current path - or infinity when not known. (RO)
AUTO_PROP float remainingDistance GetRemainingDistance
// The relative vertical displacement of the owning [[GameObject]].
AUTO_PROP float baseOffset GetBaseOffset SetBaseOffset
// Is agent currently positioned on an OffMeshLink. (RO)
CUSTOM_PROP bool isOnOffMeshLink
{
return self->IsOnOffMeshLink ();
}
// Enables or disables the current link.
CUSTOM void ActivateCurrentOffMeshLink (bool activated)
{
return self->ActivateCurrentOffMeshLink (activated);
}
// The current [[OffMeshLinkData]].
CSRAW public OffMeshLinkData currentOffMeshLinkData { get { return GetCurrentOffMeshLinkDataInternal (); } }
CUSTOM internal OffMeshLinkData GetCurrentOffMeshLinkDataInternal ()
{
OffMeshLinkData data;
self->GetCurrentOffMeshLinkData (&data);
return data;
}
// The next [[OffMeshLinkData]] on the current path.
CSRAW public OffMeshLinkData nextOffMeshLinkData { get { return GetNextOffMeshLinkDataInternal (); } }
CUSTOM internal OffMeshLinkData GetNextOffMeshLinkDataInternal ()
{
OffMeshLinkData data;
self->GetNextOffMeshLinkData (&data);
return data;
}
// Terminate OffMeshLink occupation and transfer the agent to the closest point on other side.
CUSTOM void CompleteOffMeshLink ()
{
return self->CompleteOffMeshLink ();
}
// Automate movement onto and off of OffMeshLinks.
AUTO_PROP bool autoTraverseOffMeshLink GetAutoTraverseOffMeshLink SetAutoTraverseOffMeshLink
// Automate braking of NavMeshAgent to avoid overshooting the destination.
AUTO_PROP bool autoBraking GetAutoBraking SetAutoBraking
// Attempt to acquire a new path if the existing path becomes invalid
AUTO_PROP bool autoRepath GetAutoRepath SetAutoRepath
// Does this agent currently have a path. (RO)
AUTO_PROP bool hasPath HasPath
// A path is being computed, but not yet ready. (RO)
AUTO_PROP bool pathPending PathPending
// Is the current path stale. (RO)
AUTO_PROP bool isPathStale IsPathStale
// Query the state of the current path.
AUTO_PROP NavMeshPathStatus pathStatus GetPathStatus
//*undocumented*
AUTO_PROP Vector3 pathEndPosition GetEndPositionOfCurrentPath
//*undocumented*
CUSTOM bool Warp (Vector3 newPosition)
{
return self->Warp(newPosition);
}
// Apply relative movement to current position.
CUSTOM void Move (Vector3 offset)
{
return self->Move (offset);
}
// Stop movement of this agent along its current path.
CUSTOM void Stop (bool stopUpdates = false)
{
return self->Stop (stopUpdates);
}
// Resumes the movement along the current path.
CUSTOM void Resume ()
{
return self->Resume ();
}
// Clears the current path. Note that this agent will not start looking for a new path until SetDestination is called.
CUSTOM void ResetPath ()
{
return self->ResetPath ();
}
// Assign path to this agent.
CUSTOM bool SetPath (NavMeshPath path)
{
Scripting::RaiseIfNull (path);
MonoNavMeshPath monopath;
MarshallManagedStructIntoNative (path, &monopath);
return self->SetPath (monopath.native);
}
// Set or get a copy of the current path.
CSRAW public NavMeshPath path { get { NavMeshPath path = new NavMeshPath (); CopyPathTo (path); return path; } set { if(value==null) throw new NullReferenceException(); SetPath (value); } }
CUSTOM internal void CopyPathTo (NavMeshPath path)
{
Scripting::RaiseIfNull (path);
MonoNavMeshPath monopath;
MarshallManagedStructIntoNative (path, &monopath);
self->CopyPath (monopath.native);
}
// Locate the closest NavMesh edge.
CUSTOM bool FindClosestEdge (out NavMeshHit hit)
{
return self->DistanceToEdge (hit);
}
// Trace movement towards a target postion in the NavMesh. Without moving the agent.
CUSTOM bool Raycast (Vector3 targetPosition, out NavMeshHit hit)
{
return self->Raycast (targetPosition, hit);
}
// Calculate a path to a specified point and store the resulting path.
CSRAW public bool CalculatePath (Vector3 targetPosition, NavMeshPath path)
{
path.ClearCorners ();
return CalculatePathInternal (targetPosition, path);
}
CUSTOM private bool CalculatePathInternal (Vector3 targetPosition, NavMeshPath path)
{
MonoNavMeshPath monopath;
MarshallManagedStructIntoNative (path, &monopath);
int actualSize = self->CalculatePolygonPath (targetPosition, monopath.native);
return actualSize>0;
}
// Sample a position along the current path.
CUSTOM bool SamplePathPosition (int passableMask, float maxDistance, out NavMeshHit hit)
{
return self->SamplePathPosition (passableMask, maxDistance, hit);
}
// Sets the cost for traversing over geometry of the layer type.
CUSTOM void SetLayerCost (int layer, float cost)
{
self->SetLayerCost (layer, cost);
}
// Gets the cost for traversing over geometry of the layer type.
CUSTOM float GetLayerCost (int layer)
{
return self->GetLayerCost (layer);
}
// Specifies which NavMesh layers are passable (bitfield). Changing /walkableMask/ will make the path stale (see ::ref::isPathStale)
AUTO_PROP int walkableMask GetWalkableMask SetWalkableMask
// Maximum movement speed.
AUTO_PROP float speed GetSpeed SetSpeed
// Maximum rotation speed in (deg/s).
AUTO_PROP float angularSpeed GetAngularSpeed SetAngularSpeed
// Maximum acceleration.
AUTO_PROP float acceleration GetAcceleration SetAcceleration
// Should the agent update the transform position.
AUTO_PROP bool updatePosition GetUpdatePosition SetUpdatePosition
// Should the agent update the transform orientation.
AUTO_PROP bool updateRotation GetUpdateRotation SetUpdateRotation
// Agent avoidance radius.
AUTO_PROP float radius GetRadius SetRadius
// Agent height.
AUTO_PROP float height GetHeight SetHeight
// The level of quality of avoidance.
AUTO_PROP ObstacleAvoidanceType obstacleAvoidanceType GetObstacleAvoidanceType SetObstacleAvoidanceType
// The avoidance priority level.
AUTO_PROP int avoidancePriority GetAvoidancePriority SetAvoidancePriority
END
CSRAW }
|