Lagless pinning? is it possible?

0 favourites
  • 12 posts
From the Asset Store
Wall Pin Board is a hyper causal game developed for fun and inspired by YouTube video whose link is given in description
  • I want to pin a large amount objects, once spawned, to a moving object. the objects spawn at various intervals.

    Currently, using "pin" there is a lot of lag and it just isn't working as I hoped it should.

    I noticed one person had an issue with lagging pinned objects and Ashley uploaded an example to dropbox, but the file is gone..

    Can anyone kindly assist or even tell me if lagless pinning is possible?? if not by the pin function, is there another method??

    Kind and humble thanks as always.

  • Could you share a capx demonstrating the problem?

  • dop2000

    Yet again, thanks for your response..

    I wrote a small standalone example CAP to show an example - , but it didnt happen in that - Then I noticed in the game I am working on, that once the main game loop was disabled (via my pause function) the laggyness was virtually eliminated.

    I also noticed in my game that even though the PIN function was being called in the next event after creation, it wasn't immediately being pinned, in fact it was happening around 1 second after the object was created.

    I know Ashley mentioned that behaviours dont execute in any particular order, so I am assuming it is because of other behaviours.. ?

    I don't really want to send my WIP game over as it's full of graphics, music etc - I'll have to delete a ton of stuff so I can send a small cap..

    Just as a query what is the standard procedure for pinning an object, create then pin, right?? it doesn't need an every tick function or anything, I am assuming??

    Thanks again..

  • I know one scenario where Pin behavior can cause lagging:

    Create 3 sprites A, B, C.

    Add Bullet or Drag and Drop behavior to A.

    Pin B to A.

    On every tick set C sprite position to (B.x, B.y)

    You'll see that A and B move together, but C is lagging behind. I'm guessing that's because Pin behavior updates coordinates of pinned objects at the end of the frame, after all other behaviors and events.

    So maybe you have something similar in your game. The solution would be not to use (x, y) coordinates of pinned objects in any events or calculations.

    [quote:15t8snbl]Just as a query what is the standard procedure for pinning an object, create then pin, right?? it doesn't need an every tick function or anything, I am assuming??

    Correct. Create and pin, no need to "re-pin" on every tick.

  • A second delay is a bug in your event code. The pin behavior runs once per frame and typically there is no lag at all. A one frame lag can be possible when using multiple behaviors are used. It’s basically due to the order of behaviors being run. A multiframe lag can be possible in cases of pinning to objects pinned already.

    Anyways you can always just position objects with events. With that you can control when you do it, or even do it multiple times in events if you move object around a lot.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • So maybe you have something similar in your game. The solution would be not to use (x, y) coordinates of pinned objects in any events or calculations.

    .

    Noted and fixed. Thankyou!

  • A second delay is a bug in your event code. The pin behavior runs once per frame and typically there is no lag at all. A one frame lag can be possible when using multiple behaviors are used. It’s basically due to the order of behaviors being run. A multiframe lag can be possible in cases of pinning to objects pinned already.

    Anyways you can always just position objects with events. With that you can control when you do it, or even do it multiple times in events if you move object around a lot.

    R0J0hound

    It seems that the multiple pinning was the issue, the family and the object had a pin function.. Thanks!

    Can you be so kind as to give me an example of positioning with events? Now I have things moving smoother, I worry that the pin function, while easy, may cause more trouble when I start adding some more complex attributes...

  • Positioning with events can be as easy as setting an object position to another objects position or one of it's imagepoints.

    You can also save the offset and just set the position from that. Like this more or less. There are more deluxe ideas too.

    Start of layout

    --- set dx to child.x-parent.x

    --- set dy to child.y-parent.y

    every tick

    --- child: set x to parent.x+dx

    --- child: set y to parent.y+dy

  • Positioning with events can be as easy as setting an object position to another objects position or one of it's imagepoints.

    You can also save the offset and just set the position from that. Like this more or less. There are more deluxe ideas too.

    Start of layout

    --- set dx to child.x-parent.x

    --- set dy to child.y-parent.y

    every tick

    --- child: set x to parent.x+dx

    --- child: set y to parent.y+dy

    Would you know any methods to get an object moving along a path that is pinned / positioned? so both the path and the object travelling along it are all synced to a single moving object?

    I hoped the spline path plugins would be of use, but after a point is set, it seems the XY position of each point is unchangeable, so I cant move the path in its entirety and have an object travel along its path between the spline points while the object on the path is also pinned to the moving object.

    I guess the best way to envision it, is to imagine a drifting, floating island that has a car on it, driving around a set path..

  • If you move the island over the path so they are lined up and save the x,y position of the island to some vars: startx, starty then you can have some sprite dummySprite that you move along the path as normal, only you'd make that invisible. Then you can move the island anywhere and set the position of another sprite to

    x = island.x+dummySprite.x-startx

    y = island.y+dummySprite.y-starty

    and the path will move with the island.

  • R0J0hound Thanks so much for your time and help.

  • Another thing that can cause pin lag is the folder structure in your projects bar, it can changes the order in which objects get updated. I tweeted about this https://twitter.com/2xTacker/status/917781791066423296 the gif shows what i mean pretty well.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)