Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JoystickMoveToPosition not working as expected #115

Closed
KyleKun opened this issue Jun 6, 2021 · 18 comments
Closed

JoystickMoveToPosition not working as expected #115

KyleKun opened this issue Jun 6, 2021 · 18 comments
Labels
bug Something isn't working

Comments

@KyleKun
Copy link
Collaborator

KyleKun commented Jun 6, 2021

Hello,

I'm trying to use JoystickMoveToPosition on my map built with tiled where my objects have polygon collision, but the a_star algorithm seems to not detect them, resulting in locking the player as shown in the video:

Screen_Recording_20210606-183952.mp4
@RafaelBarbosatec
Copy link
Owner

Hi @KyleKun !
Those elements that contain collision were added as Decoration or by Tiled

@KyleKun
Copy link
Collaborator Author

KyleKun commented Jun 8, 2021

By Tiled only

@RafaelBarbosatec
Copy link
Owner

humm. Ok
I will try to reproduce here. can you send a print with the showCollisionArea property equal to true?

@KyleKun
Copy link
Collaborator Author

KyleKun commented Jun 8, 2021

20210608_205001.jpg

It's very difficult to see because of the color but the collision is there, player collides with normal joystick

@KyleKun
Copy link
Collaborator Author

KyleKun commented Jun 8, 2021

I've tested a little bit more and it seems that collisions are overlapping and this is the cause of "locking" the player, player's collision enters the object's collision

@RafaelBarbosatec
Copy link
Owner

Understand. I will try to simulate a scenario similar to yours. Because it wasn't to trace a route that passes through the objectives that have collision.
In the example of the package it works perfectly.
I'll investigate further.

@RafaelBarbosatec
Copy link
Owner

Could you send me a print with constructionMode: true ?
Just to get a sense of the tileSize of the map.
Because if there is something collision on the tile. it already discards that option as a path.
I've already noticed an adjustment that needs to be done.

@KyleKun
Copy link
Collaborator Author

KyleKun commented Jun 9, 2021

Sure, tileSize is 16x16 and "double tileSize" is 20.0 on main.dart

Map is small: Screenshot_20210609-161805_Gallery.png

@RafaelBarbosatec
Copy link
Owner

I've already identified the problem. I'm thinking here of a way to solve this. Hahaha
I set up a matrix to send the algorithm to calculate the path. But in this matrix I'm noticing that a very large collision object occupies more than one cell in the matrix and I wasn't considering that.

@RafaelBarbosatec RafaelBarbosatec added the bug Something isn't working label Jun 11, 2021
@RafaelBarbosatec
Copy link
Owner

Hi @KyleKun
I guess what resolve this problem.
Fiz available in 1.1.2 version.
I also updated the documentation with more information about this functionality.
https://bonfire-engine.github.io/#/path_finding

I hope it’s works good 😊

@KyleKun
Copy link
Collaborator Author

KyleKun commented Jun 11, 2021

Will test it asap, thanks very much!

@KyleKun
Copy link
Collaborator Author

KyleKun commented Jun 12, 2021

The scenario with the table and chairs is fixed, but it still happens in some places, see these 2 videos:

Screen_Recording_20210612-130748.mp4
Screen_Recording_20210612-130929.mp4

@RafaelBarbosatec
Copy link
Owner

RafaelBarbosatec commented Jun 14, 2021

Hi @KyleKun
Try uses 1.1.4 version.

@KyleKun
Copy link
Collaborator Author

KyleKun commented Jun 14, 2021

Hi @RafaelBarbosatec ,
It still happens in some places, and now the player movement is a little "shaky", check the video:

output.mp4

I've 2 suggestions but maybe they are quite complex to implement:

  1. Somehow trace the shortest path without having to go through the center of the tile, it would make the movement more natural

  2. Add some default space between player collision and any object collision (very little space), just to make sure that even if the path shocks with something, the player won't be stuck on the object's collision and it will be possible to click somewhere else

@RafaelBarbosatec
Copy link
Owner

RafaelBarbosatec commented Jun 15, 2021

Hi @KyleKun !

Good suggestions. I will work on it.
In this specific case it is because it currently checks for visible collisions on the screen. and on this particular route, he had to turn around and pass a chair that wasn't on the screen.
I can fix it too. increasing the size of the space for route analysis.

@RafaelBarbosatec
Copy link
Owner

You can check theses spaces that is considered collision adding:

        setupMoveToPositionAlongThePath(
            showBarriersCalculated: true, 
        )

in the player constructor.

@RafaelBarbosatec
Copy link
Owner

Hi @KyleKun !
Retest with the latest version please

@KyleKun
Copy link
Collaborator Author

KyleKun commented Jun 21, 2021

It works like a charm!
I'll be closing this issue, thank you once again xD

@KyleKun KyleKun closed this as completed Jun 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants