new SimplePathComponent(pOwner)
The simple path component can make a game object follow a predefined path.
Parameters:
Name | Type | Description |
---|---|---|
pOwner |
FM.GameObject | The game object that owns this component. |
Extends
Members
-
name :FM.ComponentTypes
-
Component's name.
Type:
- Inherited From:
- Source:
-
owner :FM.GameObject
-
Component's owner.
Type:
- Inherited From:
- Source:
Methods
-
add(pX, pY, index)
-
Add a waypoint to the path.
Parameters:
Name Type Description pX
int X position. pY
int Y position. index
int Optional index at which adding the waypoint. -
clearPath()
-
Erase every waypoints in the path.
-
destroy()
-
Destroy the path.
-
getCurrentIndex() → {int}
-
Return the current index of the waypoint to reach.
Returns:
Index of the waypoint to reach.- Type
- int
-
getCurrentWaypoint() → {Object}
-
Return the current waypoint to reach.
Returns:
Waypoint to reach, a literal with a x and y property.- Type
- Object
-
getLength() → {int}
-
Return the number of waypoints.
Returns:
Number of waypoints.- Type
- int
-
getWaypoints() → {Array}
-
Return the waypoints of the path.
Returns:
Waypoints of the path.- Type
- Array
-
isActive() → {boolean}
-
Check if the path is being followed.
Returns:
Whether the path is being followed.- Type
- boolean
-
isLastWaypointReached() → {boolean}
-
Check if the last waypoint has been reached.
Returns:
Whether the last waypoint has been reached or not.- Type
- boolean
-
remove(pIndex)
-
Remove a waypoint from the path.
Parameters:
Name Type Description pIndex
int Index of the waypoint to remove. -
resumeFollowingPath()
-
Continue following the current path where it had stopped.
-
startFollowingPath(pSpeed, pIndexToStartFrom)
-
Follow the specified path.
Parameters:
Name Type Description pSpeed
int Speed at which the game object must follow the path. pIndexToStartFrom
int The index at which the game object should start following the path. -
stopFollowingPath()
-
Stop following the current path.
-
update(dt)
-
Update the component.
Parameters:
Name Type Description dt
float Fixed delta time in seconds since the last frame.