How do I Keep Two objects near eachother

0 favourites
From the Asset Store
This is a Dungeon Master tool & the 1st of 12 Combat Engines from the Building Combat Engines for Browser Games workshop
  • Essentially I am spawning objects that scroll down the screen. For the most part they spawn and stay where they are supposed to. But sometimes they will be too far apart. How can I bring the objects together?

    Is there a way to check if a specific image point is in collision?

  • Bump.

    And some better explanation.

    I have two+ objects falling. I always want the object on top to be in contact with the object below it.

    If there is a way to check if an image point is in the collision that would be great. Otherwise are there any other workarounds?

    I spawn them and have them moving the same speed but over time these objects get further apart creating gaps.

  • Can you show an example don't understand what you mean?

  • click and let it run for a little bit

    I should mention I have been doing a good deal of optimizations, so it takes a minute or two before the issue happens. Out of ideas on improving it even further though.

  • Ok can see what you mean. However its hard to pin point where the problem is, how do you match them together?

    Is it a set position to imagepoint or are they pinned?

  • Ok can see what you mean. However its hard to pin point where the problem is, how do you match them together?

    Is it a set position to imagepoint or are they pinned?

    Those rectangles at the top are spawners. They spawn to image points.

    Everytime a line touches at the bottom it is destroyed and a new one is spawned.

    My theory originally was as follows:

    I have the objects spaced equally

    The spawner and destroyer are also spaced evenly.

    If I destroy an object and create it at the same step, then the spacing should remain true and have no gaps.

    Obviously this does not work, or there are some pixel errors based on custom movement.

    Now I need a way to adjust for this and prevent this gap from happening.

    edit:

    Another reason for error i imagine is as the objects get faster they might overlap the bottom destroying object and this creates offsets as well.

  • Think you misunderstood what I meant.

    Im talking about the shapes that drops, how do you make them stick to each other? But from you description I assume that you don't, and you just apply the same speed to all of them?

  • Think you misunderstood what I meant.

    Im talking about the shapes that drops, how do you make them stick to each other? But from you description I assume that you don't, and you just apply the same speed to all of them?

    Exactly. Currently they are not stuck together. Only the same speed is applied

  • Can you post the code might be easier. As I noticed it seemed to start lagging at the speed increased so maybe there are something not quite right?

  • Can you post the code might be easier. As I noticed it seemed to start lagging at the speed increased so maybe there are something not quite right?

    Essentially:

    On Line Created
    {
    Line speed= gamespeed;
    } 
    
    Every 5 seconds
    {
    Gamespeed+=15;
    Line speed= gamespeed;
    }
    
    Objects overlap(Line&EndLine)
    {
    Line.destroy;
    line.create;
    }
    [/code:32dhhkx1]
  • hmm nothing in the code that you posted seems to be wrong. Can you try to post a Capx of the whole project?

  • Not much to go on need CAPX to look at

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hopefully this is useful to finding a solution to my problem. CapX attatched

  • I have thought of two possible solutions but would love some help in implementation.

    1. Pick the nearest line piece from the top and spawn the next piece from it.

    -What I need help with-

    I dont know how to actually pick the nearest piece. Or rather, I dont know how pick nearest works.

    Pick Nearest Line
    {
      Line spawn(another line)
    }
    [/code:2ss8yw0c]
    That is sort of how I thought things should work. I have the condition set as pick nearest line. and then the action is for lines to spawn the next piece.
    
    Anyways an explanation on using pick nearest would be awesome.
    
    2. My other idea is to use the check overlapping offset.
    I ran into the problem of this seemingly not working at all...
    I tried to stop it from picking the bottom line with an inverted pick bottom object. But still I would need some help with this method as well.
    
    Those are my two new ideas of implementation.
    
    But I still need help with either my former code, or these new ideas.
  • I looked at it, and it seems like it just cant keep up, for some reason. Not sure how to solve something like that. I tried to just use a every tick and set the Y value, but it was the same thing. Not sure it will work even with a pin or overlapping check, if it cant keep up without. It might be more solid, but might result in it seeing like its lagging or something. Maybe someone have made something similar that have a solution.

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