question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Grid engine failing to snap to grid after version >= 2.17.0

See original GitHub issue

Hey folks!

I’m creating a MMORPG here and this lib is one of my critical libs. My character suddenly stopped to snap to the grid after I was updating my dependencies about 2 days ago. It took me almost 8 hours to realize that this was because I had a:

    "grid-engine": "^2.12.0",

On my package.json, so yarn was automatically updating it to the latest version (2.19.0)

Once I figured out the problem, I noticed that it started from 2.17.0 above.

Screenshot (1)

Screenshot (13)

Here’s my implementation code:

import { FromGridX, FromGridY, ToGridX, ToGridY } from '@rpg-engine/shared';
import { IComponent } from '../../abstractions/ComponentService';
import { Entity } from '../../abstractions/Entity';

export class EntityGrid implements IComponent {
private gameObject: Entity;

public init(targetObject: Entity) {
  this.gameObject = targetObject;
}

public awake() {
  // this whole offset and displayOrigin adjustments are required because our entity sprites are 32x32 while our tileset is 16x16

  this.gameObject.scene.grid.addCharacter({
    id: this.gameObject.id,
    sprite: this.gameObject,
    // walkingAnimationMapping: 6,
    startPosition: {
      x: ToGridX(this.gameObject.x),
      y: ToGridY(this.gameObject.y),
    },
    speed: this.gameObject.speed,
    charLayer: 'character',
    collides: false,
  });

  // make sure our sprite position and grid position are the same, to avoid inconsistencies
  const { x: gx, y: gy } = this.gameObject.scene.grid.getPosition(this.gameObject.id);
  this.gameObject.x = FromGridX(gx);
  this.gameObject.y = FromGridY(gy);
}
}

My fix was rolling back to the 2.16.0 version.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
jonit-devcommented, Aug 4, 2022

@Annoraaq it seems to have solved. Thank you!

0reactions
Annoraaqcommented, Aug 2, 2022

I just patched a bug related to the offset in v2.19.1. Can you check, if that solves your problem?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Change Log (Unreal Engine) - Dungeon Architect
Version 2.17.0 · Critical Fix Fixed a crash bug in stand alone builds when using the snap map builder and level streaming ·...
Read more >
Finding applications that use Log4J - runZero
Log4J versions since 2.0 are reported to contain this vulnerability, which was originally disclosed to Apache several weeks ago by the security ...
Read more >
Things don't snap to grid - Bugs - Corel Vector discussion
Chromebook (12239.92.0)/ web-based version 2020-1.3.1/ ... I'm having problems with is the black box) when I try to snap to grid it only...
Read more >
Hookpad Release Notes 2.11 - 2.17 - Hooktheory Forum
These are archival release notes from version 2.11 - 2.17 of Hookpad ... 2.17.0 (2020.08.25) ... New app setting for cursor snap grid....
Read more >
PlanGrid FAQs - Comparably
PlanGrid FAQs. PlanGrid's Frequently Asked Questions page is a central hub where its customers can always go to with their most common questions....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found