Positioning

  • Hi guys I,

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hi LaurenceBedford, assuming you have a looped track, this might work, haven't tried it out yet though:

    Create a sprite object called "trackSection" and give the object two instance variables called "position" and "sectionNo" Place instances of this sprite contiguously around the track setting sectionNo=1 to the first section and stepping up by one for each subsequent section. You can set the sprites invisible.

    Give your cars instance variables of "sectionNo" and "position" as well, starting both on 0.

    Use this code:

    If car is overlapping with trackSection & car.sectionNo<trackSection.sectionNo, trigger once:

    set trackSection.position to self.position+1

    set car.position to trackSection.position

    set car.sectionNo to trackSection.sectionNo

    As each car passes over the section it tags itself with the current position value of that section which steps itself up for the next car. Tagging the car with the current section number and checking to make sure that it's less than the current section that its on prevents bugs from the cars backtracking into a previous section.

    Essentially what you're doing is running a sequence of small races and check the winner for each section. You want to keep each section fairly small so that it captures place changes quickly.

  • In fact the track section sprites don't need to be touching, as long as each spans the width of the track and they're deep enough to register a car passing at speed i.e. the car isn't moving further than the depth of the section in a single tick.

  • mekonbekon sounds good ill try if you visit my profile and play my racing game you will see the set out

  • LaurenceBedford

    This is the basic idea:

    https://www.dropbox.com/s/2tmcnhi1mngfe ... .capx?dl=0

    The code I discussed above is in Event 2; the rest of the code is only there to get the cars moving.

    You can make the positioning more accurate by adding more trackSections in.

    Hope that helps! <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">

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