0
\$\begingroup\$

To get the cars to follow the circuit, I mapped the circuits to several points. And using the move_towards_point function I make everything happen correctly.

In addition, I use two objects: object 1 / pink square => to be followed by the cars, object 2 \ green square => to reset the car collision with object 1 (so that the collision with object 1 only happens once).

Sometimes I have to make an adjustment in the position of object 2, because it has to be in the path between two objects 1, otherwise it will not clear the collision.

enter image description here

I thought there would be another solution considering that I've seen in video tutorials a platform games function (usually used on villains so they do not fall into the void).

enter image description here

If I am not mistaken, it is as if at any moment the object throws a particle, and if it did not reach anything until a certain moment or height (y), the object would turn around and run in the opposite direction.

I imagine there is a function similar to this to use in my case. So that you detect the circuit object and do not let the car get out of it.

It's hard enough to have to put up points, then move the position of each of them to the code (I had to do this, because I preferred to create only one object and keep repeating it all over the circuit, I could have created several. Ex => point 1, point 2, ...).

Not wanting to plagiarize, but an example of what I want for my game, is this game:

Game: https://play.google.com/store/apps/details?id=com.moz.flracing2016.pro&hl=pt_BR

Video of game: https://www.youtube.com/watch?v=knZRQZI25Fo

\$\endgroup\$
5
  • \$\begingroup\$ Usually those voids are detected with place_free, throwing particles seems tricky for this purpose. Could you use a path for the circuit? \$\endgroup\$ – Juanpa Dec 28 '18 at 1:20
  • \$\begingroup\$ @Juanpa What do you mean by using a path to the circuit? \$\endgroup\$ – Boneco Sinforoso Dec 28 '18 at 21:10
  • 1
    \$\begingroup\$ A game maker resource called "Path" \$\endgroup\$ – Juanpa Dec 28 '18 at 21:52
  • \$\begingroup\$ @Juanpa It worked, it turns out that I can not get each car to start in a different position (like on a starting grid) without having to mark with false the absolute option. \$\endgroup\$ – Boneco Sinforoso Dec 29 '18 at 0:05
  • \$\begingroup\$ I got it! Just add a value to the variable path_position. The value of the variable is defined as a percentage of the path length. See: docs.yoyogames.com/source/dadiospice/002_reference/paths/… \$\endgroup\$ – Boneco Sinforoso Dec 29 '18 at 0:36
0
\$\begingroup\$

Through the comment from site member Juanpa, I got a simpler way of doing what I wanted at first.

The GameMaker has a feature called path.

enter image description here

By clicking on the path, you can choose a room as the background (the room is already with the circuit drawing, so I can draw the path above the circuit drawing):

enter image description here

You click at any point to start the path:

enter image description here

After setting the starting position of the maze, the next point will be the next location of the path to be followed (see that with 3 or more points the path closes, this is because the closed option is selected):

enter image description here

Path completed:

enter image description here

Below is a link that will help you use some of the important features of this feature:

https://docs.yoyogames.com/source/dadiospice/001_advanced%20use/004_paths.html

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.