Skip to content

Commit

Permalink
fix(client): teleport animation bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Veradictus committed Sep 15, 2023
1 parent b515a63 commit 3c1b90a
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/client/src/entity/character/character.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ export default class Character extends Entity {

public follow(entity: Entity, forced = false): void {
// Prevents follow spam which will cause entities to visually vibrate.
if (Date.now() - this.lastFollow < 200) return;
if (Date.now() - this.lastFollow < 300) return;

// Prevent following when entity is stunned or dead.
if (this.dead || this.isStunned()) return;
Expand Down
2 changes: 2 additions & 0 deletions packages/client/src/entity/entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@ export default abstract class Entity {
*/

public setSprite(sprite: Sprite): void {
if (this.teleporting) return;

// Load the sprite if it hasn't been loaded yet.
if (!sprite.loaded) {
sprite.load();
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/menu/equipments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ export default class Equipments extends Menu {
{ sprite } = this.player;

// Ensure we have a valid sprite and context before drawing anything.
if (!context || !sprite) return;
if (!context || !sprite || sprite.key === 'death') return;

if (flip) frame = 'right';

Expand Down
6 changes: 3 additions & 3 deletions packages/client/src/network/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -475,12 +475,12 @@ export default class Connection {
// Copy the entity's sprite temporarily.
let entitySprite = entity.sprite.key;

// Prevent rendering of the sword.
entity.teleporting = true;

// Set the entity's sprite to the death animation sprite.
entity.setSprite(this.sprites.getDeath());

// Prevent rendering of the sword.
entity.teleporting = true;

entity.animateDeath(() => {
this.game.teleport(entity, info.x, info.y);

Expand Down

0 comments on commit 3c1b90a

Please sign in to comment.