Class IsoCharacter
Constructor Attributes | Constructor Name and Description |
---|---|
This is a behavior to be used by characters in the isometric world of wade.iso.
|
Field Attributes | Field Name and Description |
---|---|
The maximum height difference between two tiles that will allow this character to move from one tile to the next.
|
|
The movement speed of the character (in world units per second).
|
|
The name of the behavior.
|
|
How likely it is that an idle animation (if present) will be played when the character is idle
|
Method Attributes | Method Name and Description |
---|---|
Remove any destinations that were added with setDestination()
|
|
Get the next destination
|
|
goToObject(object)
Move towards an object.
|
|
setDestination(gridCoords)
Set a destination (a tile to move to) for the character.
|
|
setDirection(direction)
Set a direction to face.
|
|
setMovementType(type)
Set a movement type for this character.
|
|
startWandering(probability, stepDistance, targetObject)
Start moving around in random directions
|
|
Stop moving around in random directions
|
Class Detail
IsoCharacter()
This is a behavior to be used by characters in the isometric world of wade.iso. It handles movement, pathfinding, movement queues, and more.
Field Detail
maxStepHeight
The maximum height difference between two tiles that will allow this character to move from one tile to the next. Default is 20.
movementSpeed
The movement speed of the character (in world units per second). Note that changing this won't affect any movement that is currently in progress, only future movements. Default is 160.
name
The name of the behavior. This is set to 'IsoCharacter'.
variationProbability
How likely it is that an idle animation (if present) will be played when the character is idle
Method Detail
clearDestinations()
Remove any destinations that were added with setDestination()
{Object}
getNextDestination()
Get the next destination
- Returns:
- {Object} An object with x and z fields representing the next destination, or null if there are no destinations in the queue
goToObject(object)
Move towards an object. If the object has an interactionOffset field set in its object data, the character will try to go there. If that is not possible (or no interaction offset is set) the character will try to move to the object's tile. If that is not possible (because the object has a collision map), it will try to move to any tile next to the object
- Parameters:
- {SceneObject|string} object
- An object (or a string with the name of the object) to move towards.
{boolean}
setDestination(gridCoords)
Set a destination (a tile to move to) for the character.
- Parameters:
- {{x: number|z: number}} gridCoords
- The isometric tile coordinates to move to
- Returns:
- {boolean} Whether it was possible to add the destination (i.e. it isn't blocked by objects with collisions)
setDirection(direction)
Set a direction to face. This will change the idle animation that is currently playing, and won't have any effect if the character is moving.
- Parameters:
- {string} direction
- The direction to face. It can be one of ['n', 'e', 's', 'w'] (if you have set the isometric movement type to 'straight'), one of ['ne', 'nw', 'se', 'sw'] (if you have set the isometric movement type to 'diagonal', which is the default), or any one of either set (if you have the isometric movement type ot 'both')
setMovementType(type)
Set a movement type for this character.
- Parameters:
- {string} type
- A string describing the movement type. It can be 'diagonal', 'straight' or 'both'. If omitted, the character will use the default movement type (the one that was set with wade.iso.init(), or, if it wasn't set, 'diagonal').
startWandering(probability, stepDistance, targetObject)
Start moving around in random directions
- Parameters:
- {number} probability
- A number between 0 and 1 indicating the movement probability. Lower numbers will make the character move less often.
- {number} stepDistance
- The maximum number of tiles that each movement can span
- {SceneObject|string} targetObject Optional
- An isometric object (or its name as a string) that the character will try to keep close to while wandering.
stopWandering()
Stop moving around in random directions