NodeMover: Difference between revisions
From Crumbled World Wiki
 (Created page with "{{:NodeMoverExampleCode}}  ==Constructor== {| class="wikitable"  !|function !|description |- |NodeMover(SceneNode nodeToMove, float walkSize, float walkSpeed, float pathOffset) |pathOffset accept a value bettwen [-1,1]. |- |}  ==Functions== {| class="wikitable" !|return !|function !|description |- |bool |isAtFinalDestination() |Returns true if the node has reach the final destination. |- |Vec3 |NodeMover:getFuturePosition(fl...")  | 
				|||
| (One intermediate revision by the same user not shown) | |||
| Line 41: | Line 41: | ||
|[[NodeMover:getTargetGlobalPosition()|getTargetGlobalPosition]]()  | |[[NodeMover:getTargetGlobalPosition()|getTargetGlobalPosition]]()  | ||
|Return the next Path points global position  | |Return the next Path points global position  | ||
|-  | |||
|[[Vec3]]  | |||
|[[NodeMover:getPositionFromFrame(number frameId)|getPositionFromFrame]](number frameId)  | |||
|get a position from a frame, we only store position for 5 frames  | |||
|-  | |-  | ||
|float  | |float  | ||
| Line 47: | Line 51: | ||
|-  | |-  | ||
|Table  | |Table  | ||
|[[NodeMover:getPathPoints()|getPathPoints]]()  | |[[NodeMover:getPathPoints(float ignorePointsWithinDistance)|getPathPoints]](float ignorePointsWithinDistance)  | ||
|Return main pathPoints. return in format '''{{navMeshPos = [[Vec2]](), localIslandPos = [[Vec3]](), islandId = number()},...}'''  | |Return main pathPoints. return in format '''{{navMeshPos = [[Vec2]](), localIslandPos = [[Vec3]](), islandId = number()},...}'''  | ||
|-  | |-  | ||
Latest revision as of 08:23, 4 August 2025
Constructor
| function | description | 
|---|---|
| NodeMover(SceneNode nodeToMove, float walkSize, float walkSpeed, float pathOffset) | pathOffset accept a value bettwen [-1,1]. | 
Functions
| return | function | description | 
|---|---|---|
| bool | isAtFinalDestination() | Returns true if the node has reach the final destination. | 
| Vec3 | getFuturePosition(float time) | Get the future position of the node, after a set time. (This only works if the entire path is known, special case is the mine cart which this may not be true for.) | 
| Vec3 | getCurrentPosition() | Return the current global position. | 
| Vec3 | getCurrentVelocity() | Return the current velocity. | 
| float | getCurrentSpeed() | Return the walk speed. | 
| Vec3 | getTargetGlobalPosition() | Return the next Path points global position | 
| Vec3 | getPositionFromFrame(number frameId) | get a position from a frame, we only store position for 5 frames | 
| float | getDistanceToExit() | Return distance to exit. | 
| Table | getPathPoints(float ignorePointsWithinDistance) | Return main pathPoints. return in format {{navMeshPos = Vec2(), localIslandPos = Vec3(), islandId = number()},...} | 
| Table | setPathPoints(Table pathPoints) | Set main pathPoints same format as given by getPathPoints(). | 
| setWalkSpeed(float walkSpeed) | Set walk speed | |
| setMaxWalkSpeed(float maxWalkSpeed) | Caps the speed that the npc can walk. speed = min(walkSpeed,maxWalkSpeed) | |
| setWalkSize(float size) | Set the size of the npc | |
| addCallbackWayPointReached(string functionName) | Function name | |
| addMoveTo(SceneNode island, Vec3 localPosition) | ||
| followNode(SceneNode node) | ||
| update() | Update the nodeMover and move the node towards the final position. |