Waypoint Paths

From HEWIKI
Jump to: navigation, search

Contents

Waypoint paths are constructed with Path nodes, which contain a list of waypoints which are discrete positions in 3D space.

See also

Overview

Paths can be used for a variety of things such as:

Paths, and their waypoints, are created in HeroBlade by the area designer (never in HeroScript).

Creating a Path

Via the Paths Panel, various waypoints are added. These waypoints can be dragged around and placed exactly, just like any other graphical element.

Important:

For more information about creating and configuring a path, please see the Path Tutorial.


Related Functions

Waypoints can be checked with the appropriate functions:


Get Start Waypoint

  GetStartWaypoint(path as noderef) as ID

This function returns the ID of the first waypoint in the specified path.

Example:

  startID as ID = GetStartWaypoint(path)


Get End Waypoint

  GetEndWaypoint(path as noderef) as ID

This function returns the end waypoint in the specified path.

Example:

  endID as ID = GetEndWaypoint(path)

Get Waypoint Location

This function returns the world space location of the specified waypoint in the specified path, as a Vector3.

  GetWaypointLocation(path as noderef, waypoint as ID) as Vector3

Example:

  wplocation as Vector3 = GetWaypointLocation(path, waypoint)

Get Next Waypoint

  GetNextWaypoint(path as noderef, pointID as ID) as ID

This function returns the next waypoint after pointID in path. If it is given the last waypoint, it returns a value of 0. Example:

  nextID as ID = GetNextWaypoint(path, pointID)

Get Nearest Waypoint

  GetNearestWaypoint(path as noderef, location as vector3)

This function returns the next closest waypoint of this Path, given the specified location. Note that this is an "as the crow flys" sense of closest -- it may not necessarily mean the easiest one to get to!

Example:

  nearestID as ID = GetNearestWaypoint(path, location)

Get Previous Waypoint

  GetPrevWaypoint(pathnode, pointID)

This function returns the previous waypoint before pointID in path. If it is given the first waypoint, it returns a value of 0. Example:

  prevID as ID = GetPrevWaypoint(path, pointID)


Get Waypoint Data

When waypoints are selected in HeroBlade, a text box allows arbitrary text to be entered and stored with the waypoint. This function retrieves that text.

  GetWaypointData(path as noderef, waypoint as ID) as string

Example:

  comment as string = GetWaypointData( pathNode, waypointID)

Get Path by Name

  GetPathByName(pathname as string) as noderef



Followers

A path follower node moving from right to left, along a designated path

A follower is a special kind of node which can attach itself to a path, and move at a specified rate of speed. It is normally invisible, but can be viewed while editing an Area, or linked to some other node (like a boat or glowing object), and then that object will move in whatever way is specified by the path and follower. There can be multiple followers linked to a path, or no followers. For example, the arrival_01 path is used to designate where players should be sent to when they enter an area, and therefore the path does not require any followers.


Creating a Follower

Follower nodes are created in one of two ways:

Followers are always associated with a particular path, and then the Follower's properties can be adjusted to specify how fast it should move, what it should do when it arrives at waypoints or the end of a path, and so forth.

To see path followers, ensure that they are turned on in the Filters Menu.

To select path followers, go to the Paths Panel and click on Select Followers.

To start a follower moving, select it via the above method, look at its properties in the Properties Panel, and set PAUSE to FALSE.

Follower Functions

Get Followers

This function returns a list of hbnode node references that contains all followers that are set to follow the specified path.

GetFollowers(path as noderef) as list of noderef of class hbnode

Example:

 followers as List of Noderef of Class hbnode
 followers = GetFollowers(mypath)

On Follower Reached Waypoint

OnFollowerReachedWaypoint(path as noderef of class hbpath, waypoint as ID)

When a path follower reaches a waypoint, if its script field is set and this callback function exists in the specified script, it will be called with me set to the path follower. The MasterCamera script is a primary example of a script that uses this function. Note that path followers exist only on the client, and that the script being called must be a client-side script.

Reset Path Follower

ResetPathFollower(follower as noderef of class hbnode, resetRotation as boolean)

This function will reset a path follower to its starting location and set it to seek the next waypoint. If resetRotation is TRUE, it will also snap to point directly at its next waypoint. If resetRotation is FALSE, it will retain its current rotation.

Additional Information

Please also see the section on:

Example

If you add a path named Demo to an area, when you load the area, the camera will automatically start at its first waypoint, looking toward its second waypoint, and auto-select rooms (F1) will be automatically turned on, but the path will not be selected.

//
        pathNode as node
        pathNode = 42
        pointID as integer
        pointID = GetStartWaypoint( pathNode)
        v3 as vector3
        while (pointID != 0) loop
                v3 = GetWaypointLocation( pathNode, pointID)
                pointID to GetNextWaypoint( pathNode, pointID)
        .
        pointID = GetEndWaypoint( pathNode)
        pointID = GetNearestWaypoint( pathNode, v3);
//

//
        pointID = GetEndWaypoint( pathNode)
        v3 as vector3
        while (pointID != 0) loop
                v3 = GetWaypointLocation( pathNode, pointID)
                pointID = GetPreviousWaypoint( pathNode, pointID)
        .
//

See also

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox