How do I detect going backwards in a racing game?

0 favourites
  • 6 posts
From the Asset Store
75 vehicle sound effects, from real looping car engines to jet aircraft and sci-fi engines.
  • I'm making a 3D racing game using the Race Track Example as a base. Everything is working great, but I need to work out how to get it to let you know if you're travelling the wrong way on a race course.

    Like in Mario Kart how if you're going the wrong direction and Lakitu comes down and says "turn around!"

  • Put some road markers in with int 1 2 3 as sprite variables increasing clockwise. Use get nearest every second. If the sprite value doesn't increase you are going the wrong way.

    K

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Yes I have a number of checkpoints with increasing variables around the track measuring positions in the race (which is also used in the Race Track example).

    It works great for checking your position but not sure how to use them to measure going the wrong way, I feel like it wouldn't be very precise?

  • I took a quick peek into the Race Track example.

    You have the road sprite there, and they are pointing in the direction the car should be moving.

    So you can check if the car is not between that angle -X +X

    Though you have to make sure you're always setting the right angles for the road, when building new tracks.

  • Here's an idea I think may work if you're looking for instant real-time feedback you're going the wrong way...

    1. Add a fence on at least one side of your track (or just an invisible sprite)

    2. Add a unique sprite on the left and a unique sprite on the right side of your car.

    3. Assuming the wall you added will always be on the left if you're going straight - Every tick check if the left side sprite on the car is closer to the wall than the right side sprite.

    I would think the left side of your vehicle should always be closer to the left side of the track if you're going the right direction, right?

    Of course you can add extra layers of checks like if the right side is closer for more than X seconds, or elevation checks if your track overlaps...etc. this might prevent some glitches.

  • Here's an idea I think may work if you're looking for instant real-time feedback you're going the wrong way...

    1. Add a fence on at least one side of your track (or just an invisible sprite)

    2. Add a unique sprite on the left and a unique sprite on the right side of your car.

    3. Assuming the wall you added will always be on the left if you're going straight - Every tick check if the left side sprite on the car is closer to the wall than the right side sprite.

    I would think the left side of your vehicle should always be closer to the left side of the track if you're going the right direction, right?

    Of course you can add extra layers of checks like if the right side is closer for more than X seconds, or elevation checks if your track overlaps...etc. this might prevent some glitches.

    A little tip.

    My rule of thumb is to use every tick only when it is absolutely crucial for gameplay and mechanics. Especially when it comes to picking instances from a large batch.

    You can check for this once a second or even more and still get a good result for your needs.

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