Version 3.2.0 is released with these new features
Move a player/event to a position or another player
What's the point? The event will go to the position or follow another player, while avoiding obstacles. It is not pathfinding, so the character can stay blocked (it is possible to detect it) which will give a realistic movement.
event.moveTo(player).subscribe()
https://docs.rpgjs.dev/assets/move-to.mp4
Set a delay before pressing the same key
Sometimes you want to wait a while before doing the action again. For example, we don't want the player to press too quickly and repeatedly on the attack (which would give a weird animation). Also, during the animation of the attack, we want to block the player's movement. Here is the possible configuration:
import { Input, Control, Controls } from '@rpgjs/types'
export const inputs: Controls = {
// other controls and ...
[Control.Attack]: {
bind: Input.A,
delay: {
duration: 400 // ms,
otherControls: [Control.Up, Control.Down, Control.Right, Control.Left]
}
}
}
Create a temporary hitbox on the map (which can be in motion)
On the map, you can create a moving hitbox and retrieve events, tiles or shapes that collide with the hitbox. Very useful for a real time combat system ! or to create a bomb that explodes and know who has been hit
map.createMovingHitbox(
[
{ x: 0, y: 0, width: 100, height: 100 },
{ x: 20, y: 0, width: 100, height: 100 }
]
).subscribe({
next(hitbox) {
console.log(hitbox.otherPlayersCollision)
},
complete() {
console.log('finish')
}
})
Added +50 unit tests
50 additional unit tests are used to verify the stability of the project. Moreover, the use of TypeScript has been reinforced for more control