Replies: 4 comments 12 replies
-
|
Hi Andrej, great to hear you like the plugin :) So in your concrete example, you should simply use Does that help or do you mean something else by "player"? Or is there any information about the player that you would like to access from outside? If so, what concrete information is that? |
Beta Was this translation helpful? Give feedback.
-
|
I was actually looking for a way to interact with objects on the tile next
to me but still having difficulties with it because before i was using
collider to call a function for something to happen. It's just a little
hiccup im sure i will eventually figure it out :)
<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
Virus-free.
www.avast.com
<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
…On Fri, Apr 16, 2021 at 6:46 AM Johannes Baum ***@***.***> wrote:
What is the expected behavior that you would like to see?
Is it that you want the player to stop moving if it collides with a
certain object?
This is easy in arcade physics but it causes problems in "grid physics".
In a grid world the player always has a tile position. If he stops between
two tiles because of such a collision, on which tile position will he be?
Therefore in a grid world the collisions are usually tile-based. That
means that you are not checking for collisions like in an arcade way.
Moreover collision detection is done via checking if the tile the player
wants to move to is currently blocked by a colliding object or not. So
everything is about tile positions and not pixel positions. That is the big
difference to the arcade physics.
You can still use the pixel position of the player to trigger
interactions. For example if you want to shoot bullets to players, you can
check for an overlap between the bullet and the player sprite.
But for the above reason the movement can't be stopped by such an object
because that would conflict with the tile based movement. If you need such
a functionality it might be better to completely use arcade physics and
switch to a pixel based movement.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#101 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AEASDVU2H72WIJMPMVT6TODTI7MNJANCNFSM423QMSXQ>
.
|
Beta Was this translation helpful? Give feedback.
-
|
Ye actually that would be awesome. But it works as you suggested. Now with
getPosition i should be able to do function somehow to interact with those
objects so i think all set. Thank you
<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
Virus-free.
www.avast.com
<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
…On Sun, Apr 18, 2021 at 2:38 PM Johannes Baum ***@***.***> wrote:
Ok I think I see your problem now. Let's work out a solution.
You could just add the objects to the plugin and pretend they are
characters. This would enable grid physics collisions and you could get
their tile position with the 'getPosition()` method of the plugin. You
might want to turn off the walking animation for those objects (Oops, it's
missing in the docs 😨 . I will add it)
Here is an example:
const gridEngineConfig = {
characters: [
{
id: "player",
sprite: playerSprite,
walkingAnimationMapping: 6,
startPosition: new Phaser.Math.Vector2(8, 8),
},
{
id: "myObject",
sprite: objectSprite,
walkingAnimationEnabled: false,
startPosition: new Phaser.Math.Vector2(4, 4),
}
],
};
However, this would require that the "objects" must also be moved in a
grid physics fashion (only tile based movement) and further the objects
would need to be a Phaser.GameObjects.Sprite or a subclass of that.
Additionally it would probably help if we add a setTilePosition(...)
method to the plugin. So you can freely reposition your object after adding
it.
Does that help somehow?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#101 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AEASDVV5ZZ26ETWYIYMJTFTTJLVFDANCNFSM423QMSXQ>
.
|
Beta Was this translation helpful? Give feedback.
-
|
I get character by following code: |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi Annoraaq. I started using your plugin and grid system and everything is great but i dont know how to acces player as object. Like if i wanted to add collider for example:
this.physics.add.collider(player, worldLayer);
But player is just undefined and i can't acces is through id either. I just need to know how to access player from this
const gridEngineConfig = {
characters: [
{
id: "player",
sprite: playerSprite,..
Thanks
Beta Was this translation helpful? Give feedback.
All reactions