Vallar's Recent Forum Activity

  • How I do it is by checking frequently for line of sight to the destination, and when the sprite has it I stop the pathfinding behavior and start the moveto plugin.

    I didn't think of that, but I am currently using the On Arrive event to then kick in the Move To command (previously was a Set Position). It looks slightly instant, which might give the feeling of "snapping". It isn't too bad though and might actually fly by as a feature.

    Maybe another way would be to create/spawn a 1pixel transparent sprite on mouse click ..then set the 1pixel sprites position to the clicked object.X,Y origin within the same event..

    -->

    Then 'find path' to the 1pixel sprite.x,y

    and destroy the 1pixel sprite after pathfinder arrives at destination

    that might work a little better

    also If you needed to find paths to moving objects then you would just add a pin behavior to the 1pixel sprite which is pinned to object at initial mouse click

    It is a stationary object that I am moving towards. This might actually work, albeit I feel this is more of a bug in Construct 2 (r229 is what I am using) more than anything else. I doubt the intended use of "Find a path to an object's X and Y position" would just end when it reaches the general abouts of the X and Y.

  • Just curious, did you try making the actual object that is using path finding very small? Maybe reduce the size to only 1 pixel? Just to see if the theory about it stops when it touches the border of the destination?

    If it's smaller, maybe it will get closer to the destination point

    *EDIT*

    I think it's obvious that I don't really ever use path finding - so these problems are new to me also!

    ~Sol

    The moving object is 15x15 px by default. 1x1px is almost impossible for me to see. I tried with 5x5px and it doesn't get any nearer. In fact, what I discovered that the exact position of arrival is not fixed.

    So for example, if I send instance1 of moving object to another object's position it will arrive (for example, this isn't 100% true but just to give an example) at the top left of the object (inside the object not outside of its borders).

    If I choose instance2 of the moving object from another location, it will arrive at middle left instead of top left as the first instance. Clearly the targeted position if I use a sprite as the position is messed up (perhaps a bug?) or there is something I am not understanding with path finding that is going under the hood.

  • Oh my bad I didn't read your post very well it seems. Haha!

    ~Sol

    Not at all, you confirmed that the best method is what Facecrime mentioned. I didn't like the fact that Construct 2 was doing this, but apparently no other way.

    Thanks a lot!

  • A quick and dirty fix would be that pathfinding only works if the object ISN'T overlapping the destination object... then when it touches the destination to have it move to the X.Y position of the destination manually - since by the time it has touched the object the pathfinding has already done it's job.

    You could even create a small buffer around the destination (use a slightly enlarged version of the same sprite maybe) so that it "corrects" itself before it's already on-top. It might make this look a little less "oh um let me just fix myself at the last second".

    ~Sol

    Currently that is what I am doing, as mentioned by Facecrime, I do a set position at the On Arrive event for now. Once I get the basic functionality going, I'll look into making it more smooth.

  • The Destination Object X,Y position is based on its Origin image point..not its border or collision box

    it would suggest that its the size of the pathfinding cell but if you are saying you entered a size of 0 then it must be something else

    An objects position is just a destination..its no different that just stating a position....both object position and screen positions are the same thing...based on image origin

    personally I would store Mouseclick.X, Y coordinates in a Global Variable and then update and send the pathfinder to those Coordinates..

    its more accurate

    I understand that sending the Mouse X and Y positions would be easier. But the intended use won't benefit from that, unfortunately. What I want is that the moving object to arrive at the dead center of another object. If I send the Mouse X and Mouse Y, that won't always equal the dead center of the object. The user might have clicked on the borders of the object for example.

  • I tried with a cell size of 0 and still it doesn't enter through the image and reach the center of the object. I believe the object is considered arrived once it touches the borders of the object set as "destination". I followed what you said and it works when I just use the On Arrived and change position.

    Another solution I thought of is instead of setting the destination to an object, I would set the destination to an X and Y position. Still it won't move the object till the PF object would be centered on the location, but it would be far nearer than the original general position of an object.

    Thank you very much for the help!

  • Did you check the origin point to see if it is the middle of the sprite? In the image editor. Each frame can also have different origin points as well, in case you are using multiple frames.

    It is the default origin point -- I didn't mess with it; so yes, it is in the middle. I have no animations, they are all place holder art.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Hello,

    So I am trying to get an object with the default Pathfinding behavior (no changes) to move over to the same location as an object but unfortunately it isn't happening. It is either moving over to the top or bottom of the object.

    Here is what is happening:

    Here is my CAPX:

    I tried to add to Buildings.X (Buildings.Width/2) so as to get it to go in the middle of the building and same for height. It didn't work out. Thing is, you see the small green square going to the top right, right? If I change the navel colored sprite (bottom one -- target sprite) to another different sprite, it goes to the top left (even if it is the same size but slightly above the current target). If I change the position to something else it might end up at the bottom right.

    Am I missing something? Or am I doing something wrong?

  • rexrainbow

    That is exactly what I did with your example, I changed everything with my own stuff and it didn't work.

  • I could log the received message in console log. It is worked. And you can see the message data in dashboard before you close the app web page.

    Here is the minimum capx of simplemessage plugin.

    When you say you saw the message in the console log is that in my CAPX? If so, do you have any idea why it isn't displaying the chat box?

    I tried your CAPX out and it produced an error as there is no API Key in the Firebase V3 for Firebase. So what I did is that I replaced all the information in the Authentication with my own project (API Key, Server Key, Storage Key, etc...) and tried to run the app. It ran, but still whenever I type anything it doesn't show up in the chat box. Would it be a problem with my Firebase?

  • I have no idea why it does not work, you might provide a very simple test capx to me to debug it.

    Sorry to be a bother and thanks a lot for your help. Here is the CAPX:

    https://www.dropbox.com/s/9hsbwo5akhlve ... .capx?dl=0

  • Action in event 3 is sending message only, it will trigger event 4 to display received message.

    Designer does not need to display message in event 3, because event 4 in sender will also be triggered. It is different from official MP, which the sender will not receive his message.

    I am not completely sure what do you mean. If you are referring to second action in the 3rd event:

    Set Text to Test_Message.Text

    That was a debug action I already removed where it sets a different text box from the chat box (a debug text box) to confirm that this event actually runs and that the problem is Firebase related not my C2 logic.

    Right now what I have is the same exact as what you see but all the "Test_T" lines with Set text to are all removed (they are only debug ones).

    Problem is, even if the sending should trigger receiving, that doesn't happen. Am I doing something wrong? I even went to the Firebase database and found NOTHING in it. The messages aren't added to the database at all.

Vallar's avatar

Vallar

Member since 24 Mar, 2014

None one is following Vallar yet!

Trophy Case

  • 10-Year Club
  • Forum Contributor Made 100 posts in the forums
  • Regular Visitor Visited Construct.net 7 days in a row
  • RTFM Read the fabulous manual
  • Email Verified

Progress

14/44
How to earn trophies