-
I wanted to say grid-engine, and the tutorial that was written that led up to grid-engine, was great for understanding how to move on a grid in phaser. I have two questions, which hopefully I can clearly describe :). First question: I am working on a game where you move two characters with one set of controls -- if you've ever played "Baba is you", it's a similar idea to when the level has 2 "babas" on the screen. The problem is that, if the characters ever are next to each other, one of them won't move until there's a space between them. I suppose this is because of the collision check -- on a keyboard input, I use the "move" function to move both of them. Since the neighboring tile is occupied prior to the move, it won't let one of the characters move. I tried delaying the move of one of the characters (using scene.time.delayedCall), but I need to delay by a significant amount for it to work. Any ideas on making this work? Second question: In my game, I have the concept of a hole that a character can fall in, and then the other character can walk on over. I remove the character from grid-engine using the removeCharcter function, and this works for disabling the collision check, so I can walk over the character, but the depth isn't correct -- the character that's in the hole, which I've removed from grid-engine, still appears on top (depending on the direction that I approach). I am manually setting the depth of the sprite using setDepth, but it looks like it gets overridden by grid-engine anyway. Is there another way to override the sprite depth? Thanks for any suggestions! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 6 replies
-
For the first question, is there any way you'd be able to provide a gif of this issue happening? From all the examples we have of multiple characters moving, it's not usually an issue for characters to move in directions not towards other characters. For the second question, you could perhaps try setting the depth of the character than can walk over the holes? I'm not sure how to address that one. |
Beta Was this translation helpful? Give feedback.
-
Hi @artitj first of all, thank you for giving us insight into your use case. It is important for us to know which problems occur in projects so we know which features make sense. Maybe I can shed some light on the inner mechanics of grid-engine.
Blocking Chars: Manual Depth: Now let's think about how we could solve your issues. For the second one: |
Beta Was this translation helpful? Give feedback.
-
I would chuck this into a config bool and allow people to choose which behavior makes sense for their project. |
Beta Was this translation helpful? Give feedback.
Hi @artitj
first of all, thank you for giving us insight into your use case. It is important for us to know which problems occur in projects so we know which features make sense.
Maybe I can shed some light on the inner mechanics of grid-engine.
You seem to be mentioning two issues:
Blocking Chars:
Grid-Engine works as follows. If a character is NOT moving, it will block the tile it is currently standing on. If it IS moving it will block both tiles: the one it is leaving and the one it is entering.
Manual Depth:
For non-isometric maps the logic is:
Every sprite that has been added to grid-engine will get a depth (zIndex) of 1000 + y-coordinate on the…