Jump to content


Photo
* * * * * 1 votes

Top-down Car Physics. Drifting, Collisions & Ai.


  • Please log in to reply
135 replies to this topic

#1 Exylex

Exylex

    GMC Member

  • New Member
  • 216 posts

Posted 02 February 2010 - 05:43 PM

I haven't used Game Maker for quite a while now, and therefore it's kinda out of date. If someone is willing to share me an uptodate version for me to put on the first post, it would be apreciated... credit would ofcourse be given.

  • Title: Exylex Car Engine 2.1
  • Description: "GTA-like" vehicle physics with collisions, drifting and AI using ExtremePhysics.
  • GM Version: GM 8
  • Registered: Yes & No
  • File Type: .gmk & .exe
  • File Size: 54 kb(heavy gmk) 230 kb(small gmk) 2 mb(heavy exe)
  • File Link: 2.2 heavy GMK | 2.2 heavy executable
Additional Info:
Posted Image
Download the executable to try it without installing ExtremePhysics!

Heavy version:
The heavy version uses ExtremePhysics. You need to download, install and select the .gex or use the dll for projects using the car scripts. You'll need to import EP scripts when using the dll. While taking up more space, this version provides better car handling and collisions.
Downloads: 2.2 heavy .gmk (gm8)2.2 heavy, executable

Small version
The small version is using GM code only and is for users with GM lite. The biggest difference from heavy is collisions where hitting solid objects isn't as smooth and other collisions non-existent (car-car). This version still needs lots of work.
Downloads: 2.1 Small .gmk

Old versions:1.2 Pro [33kb]1.2 Lite [195kb]

Q&A Heavy:
Q:Unknown function or script! A: You need to have ExtremePhysics installed and selected, dll or extension.
Q:Wrong number of arguments! A: Use the latest version of ExtremePhysics
Q:Use DLL instead of extension? A: Yes, then you need to import scripts from 'ExtremePhysics.gml' and call extremephysics_init();.
Q:Unknown variable define_ep_world_create! A: Call extremephysics_init(); before using EP scripts. (DLL only)

todo:
  • Acceleration/break drift[both]
  • Smarter AI [both]
  • Gears[both]
  • .gm7 version[both]
  • Better collisions[Small]

Edited by Exylex, 13 September 2012 - 01:58 PM.

  • 1

#2 CrazyTM

CrazyTM

    GMC Member

  • New Member
  • 121 posts

Posted 04 February 2010 - 03:22 PM

its cool.. i like the trails and the collision effects ... didnt find any bugs so far.

nice ,.. simple to understand .

this will make some new top down race games :) i can feel it
  • 0

#3 fredcobain

fredcobain

    GMC Member

  • GMC Member
  • 165 posts

Posted 04 February 2010 - 05:34 PM

Excellent! Very Nice!

I think the best we got here!

Congrats!

=)
  • 0

#4 Exylex

Exylex

    GMC Member

  • New Member
  • 216 posts

Posted 04 February 2010 - 06:05 PM

Thanks CrazyTM & fredcobain. I hope someone would plan to use this in a game.
If that's the case i might spend some time fixing some things.

* Improve wall collisions
* Add vehicle - vehicle collisions
* Making it more flexible.

So a shout or two and i might improve the scripts. :)

Edited by Exylex, 04 February 2010 - 06:07 PM.

  • 0

#5 peter john

peter john

    GMC Member

  • New Member
  • 18 posts

Posted 05 February 2010 - 05:49 AM

Thats really a neat work!!.
  • 0

#6 pk_3270

pk_3270

    GMC Member

  • New Member
  • 15 posts

Posted 05 February 2010 - 09:55 AM

good job.... very well implemented..........
  • 0

#7 mac_joe

mac_joe

    GMC Member

  • New Member
  • 3 posts

Posted 05 February 2010 - 10:04 AM

very Good example for me to start off with a racing game ....Helpful..Physics are pretty good ..

Congrats ...


Thanks....
  • 0

#8 fredcobain

fredcobain

    GMC Member

  • GMC Member
  • 165 posts

Posted 05 February 2010 - 11:15 AM

Thanks CrazyTM & fredcobain. I hope someone would plan to use this in a game.
If that's the case i might spend some time fixing some things.

* Improve wall collisions
* Add vehicle - vehicle collisions
* Making it more flexible.

So a shout or two and i might improve the scripts. :)



I really believe it worth you spend some time with that.

This way you'll probably create the best engine for the category.

=)

If you want suggestions, I think it would be more funny if the handbrake makes a real "slide" behavior for the vehicle. like NFS series where you can even do the curves holding the hand-brake.

The way you implemented it just stops brutally the vehicle.

I'll will probably use your engine to start something.

Congrats again.

Fred.
  • 0

#9 js_123

js_123

    GMC Member

  • New Member
  • 41 posts

Posted 05 February 2010 - 12:38 PM

woh its a gud one......impressed with wall collisions, vehicle collisions like these
Making it more flexible and easy to play........
  • 0

#10 Exylex

Exylex

    GMC Member

  • New Member
  • 216 posts

Posted 05 February 2010 - 04:51 PM

Thanks CrazyTM & fredcobain. I hope someone would plan to use this in a game.
If that's the case i might spend some time fixing some things.

* Improve wall collisions
* Add vehicle - vehicle collisions
* Making it more flexible.

So a shout or two and i might improve the scripts. :GM074:



I really believe it worth you spend some time with that.

This way you'll probably create the best engine for the category.

=)

If you want suggestions, I think it would be more funny if the handbrake makes a real "slide" behavior for the vehicle. like NFS series where you can even do the curves holding the hand-brake.

The way you implemented it just stops brutally the vehicle.

I'll will probably use your engine to start something.

Congrats again.

Fred.


Yeah, sounds good. Gonna check out some car games for the right "game" behaviour.
I've started experimenting for the perfect collision handling.
But have other things besides this that i'm working on, so it might take some time :D

Edited by Exylex, 05 February 2010 - 05:00 PM.

  • 0

#11 RamboFox

RamboFox

    Tainted Fortune

  • New Member
  • 992 posts

Posted 06 February 2010 - 03:22 AM

Very nice engine you have there - but I find a few flaws with how you choose to use variables instead of GameMaker's built-in motion functions.
Interacting with other objects that use speed, and make them bounce against the car can become problematic.

Also, the steering is not responsive enough - you need to have some editable variables that allow the user to change how quickly the car steers without having to edit the scripts (not within the car object, but the scripts in the script folder)

One final thing that I'd like to point out is that the car feels like it's stuck in first gear, and is over-revving the wheels.

Apart from those minor niggles, I would like to admit that I had great fun in driving it around, and into the walls, and grin in delight as I see it deflect/turn/slide against the wall as a real car should.
Only once did I manage to break the game by going on an angle to a block, and drive half-way through it, only to slide back out of it.

Keep working on this, and it will be by far the best vehicle physics I have found on the gmc! *thumbsup*
  • 0

#12 DarkLopo

DarkLopo

    GMC Elite

  • GMC Member
  • 874 posts

Posted 06 February 2010 - 10:36 AM

Wow, this is brilliant!
Nice, i have motivation to make own racing game now :GM074:
5/5
  • 0

#13 Exylex

Exylex

    GMC Member

  • New Member
  • 216 posts

Posted 06 February 2010 - 11:09 PM

Thanks darkLopo & RamboFox.

I usually don't use inbuilt variables becouse i feel like i lose control (0-360 wrapping, 'speed' automaticly increase speed while i want to use a x+ y+ system, image_angle not avaible for lite users and so on). However, i did as you said in the new update. ::lmao::

Nearly spent the whole day on the update... (most on a system where i had collisionchecking points all over the car, just to discover another better method the last minute :) ).

Everything is mostly rewriten. Collision system work like it should and user can easier change car attributes via the init script. :)

Thanks again for the feedback RamboFox :unsure:

Edited by Exylex, 06 February 2010 - 11:10 PM.

  • 0

#14 alexduuu

alexduuu

    GMC Member

  • New Member
  • 90 posts

Posted 07 February 2010 - 05:58 AM

This is the best by far, but it does need some work. For example: When I'm driving backwards and hit a wall, I accelerate :)
  • 0

#15 Exylex

Exylex

    GMC Member

  • New Member
  • 216 posts

Posted 07 February 2010 - 02:03 PM

This is the best by far, but it does need some work. For example: When I'm driving backwards and hit a wall, I accelerate :unsure:

Thanks :)
New update, fixed that along with some other bugs. Added break power input. :)

Edited by Exylex, 07 February 2010 - 02:05 PM.

  • 0

#16 RamboFox

RamboFox

    Tainted Fortune

  • New Member
  • 992 posts

Posted 09 February 2010 - 09:58 PM

I've checked the update, and I see you've edited the drift physics so that it has become much more drivable, and that's a great improvement (and it's wonderful to see members respond to suggestions).

Testing the collision engine this time however, it seems that it won't rotate/slide off the wall (it would stick/bump against the wall rather than rotate/slide off it).

Edited by RamboFox, 09 February 2010 - 09:58 PM.

  • 0

#17 Exylex

Exylex

    GMC Member

  • New Member
  • 216 posts

Posted 09 February 2010 - 10:34 PM

Testing the collision engine this time however, it seems that it won't rotate/slide off the wall (it would stick/bump against the wall rather than rotate/slide off it).


Personal preference :o

As you probably noticed i added a link to your collision topic for extended functionality.
Haven't had so much time to play around with it to combine the two, but i'm sure anyone will
find your work perfect for a project that need better collisions then my work can offer.

:P

Edited by Exylex, 09 February 2010 - 10:57 PM.

  • 0

#18 RamboFox

RamboFox

    Tainted Fortune

  • New Member
  • 992 posts

Posted 09 February 2010 - 10:44 PM

Alright, but I can tell you certain people won't be so kind when they find that they bounce against walls ;D

Yep, I wanted to code a collision system that prevents objects from getting stuck, and decided that it would be best for me to list a couple of games that seem obviously helpful if you're going to use the collision engine :P

Edited by RamboFox, 09 February 2010 - 10:44 PM.

  • 0

#19 Devilfromhost12

Devilfromhost12

    GMC Member

  • GMC Member
  • 735 posts

Posted 09 February 2010 - 10:46 PM

Very Nice. This should help me some time.
  • 0

#20 DarkLopo

DarkLopo

    GMC Elite

  • GMC Member
  • 874 posts

Posted 12 February 2010 - 06:03 AM

Okay, i've worked with a racing car game (side-project) and i wasn't sure, how you increase the max speed, but the acceleration is smaller.
Sometimes it just screwed up, the brakes didn't work while changing acceleration, and sometimes it accelerate so fast, that the skid's made a broken line, and it was strange when i burned, then the skid's made a tractor's wheel shape. Well, so that's not bad actually...

I suggest you add these to it
-Gears
-Available to buy some new mechanism, like motor or brakes, it would be very cool cause i am not sure how to modify those scripts.
(Actually i tried but i screwed, like i said earlier. :))

Otherwise, still i think this is the one coolest example here :)
  • 0

#21 Exylex

Exylex

    GMC Member

  • New Member
  • 216 posts

Posted 12 February 2010 - 12:49 PM

Okay, i've worked with a racing car game (side-project) and i wasn't sure, how you increase the max speed, but the acceleration is smaller.
Sometimes it just screwed up, the brakes didn't work while changing acceleration, and sometimes it accelerate so fast, that the skid's made a broken line, and it was strange when i burned, then the skid's made a tractor's wheel shape. Well, so that's not bad actually...

I suggest you add these to it
-Gears
-Available to buy some new mechanism, like motor or brakes, it would be very cool cause i am not sure how to modify those scripts.
(Actually i tried but i screwed, like i said earlier. :P)

Otherwise, still i think this is the one coolest example here :)


Seems like you are using the old scripts, try downloading the most recent ones. :)

About those suggestions. I think these features goes outside the borders of this example as this is not a racing game example.
  • 0

#22 Newly Discovered

Newly Discovered

    Harmonious Genius

  • GMC Member
  • 2475 posts
  • Version:GM8

Posted 13 February 2010 - 11:36 PM

I don't think gears would be out of the borders...maybe out of the box by a bit because it's hardly ever been done on the GMC.

This engine is alright. Not too realistic feeling but it does provide decent drifts. Now all it needs is better collision physics (slide into a wall and smash you back end, the car should spin around, not stay stiff and bounce off).
Adding gears would be pretty simple, basically max_speeds per gear...or get technical about it and throw in some RPMs and restrict the acceleration.
I think adding the simple version would suffice though.

I turned up the speed to 7 and enlarged the room for more drifting space. I continue to hold up and a direction and it drifts forever...a non-stop star shape. the car drifts, spins around, holds its speed, and keeps looping back with a slight offset. I've made some neat patterns out of it but it's obviously a bug.

Edited by Newly Discovered, 14 February 2010 - 12:00 AM.

  • 0

#23 Exylex

Exylex

    GMC Member

  • New Member
  • 216 posts

Posted 14 February 2010 - 12:56 AM

I don't think gears would be out of the borders...maybe out of the box by a bit because it's hardly ever been done on the GMC.
... ...
Adding gears would be pretty simple, basically max_speeds per gear...or get technical about it and throw in some RPMs and restrict the acceleration.
I think adding the simple version would suffice though.


Fine :P Next update i'll add a boolean that turns gears on/off in the init script.

This engine is alright. Not too realistic feeling but it does provide decent drifts. Now all it needs is better collision physics (slide into a wall and smash you back end, the car should spin around, not stay stiff and bounce off).

The car does rotate slightly upon collision in this example, or do i somehow misunderstand you?

I turned up the speed to 7 and enlarged the room for more drifting space. I continue to hold up and a direction and it drifts forever...a non-stop star shape. the car drifts, spins around, holds its speed, and keeps looping back with a slight offset. I've made some neat patterns out of it but it's obviously a bug.

Busted :lol: I clearly don't test my releases enough B-) By adjusting the speed variable negatively depending the difference between move and face angle while drifting should solve this problem.


Thanks alot by spending the time that i don't on testing this example. :)
Update incoming in near future, got other things to take care of atm though.
  • 0

#24 youknowwho

youknowwho

    GMC Member

  • New Member
  • 54 posts

Posted 08 March 2010 - 01:01 AM

I have a problem... I imported the files and everything into my game and got a trying to drive non-existant surface error. I imported everything.
-edit-
okay so I took out the effects and made a secound car for a 2 player game... the car won't work with these as the arguments for the script in the step event keyboard_check('W'), ect. It spins irradically. Please help this is a cool engine.

Edited by youknowwho, 08 March 2010 - 02:14 AM.

  • 0

#25 PhYs1aTr1sT

PhYs1aTr1sT

    GMC Member

  • New Member
  • 112 posts

Posted 09 March 2010 - 12:39 PM

downloading it..... hope its goin to be useful :)
  • 0

#26 Exylex

Exylex

    GMC Member

  • New Member
  • 216 posts

Posted 11 March 2010 - 09:28 PM

I have a problem... I imported the files and everything into my game and got a trying to drive non-existant surface error. I imported everything.
-edit-
okay so I took out the effects and made a secound car for a 2 player game... the car won't work with these as the arguments for the script in the step event keyboard_check('W'), ect. It spins irradically. Please help this is a cool engine.


I think your problem is that you call keyboard_check wrong.

ord(str) Returns the asci code of the first character in str.

keyboard_check(ord('W'))
keyboard_check(ord('A'))
keyboard_check(ord('S'))
keyboard_check(ord('D'))

Should do it.
  • 0

#27 Urbanturkin

Urbanturkin

    GMC Member

  • GMC Member
  • 230 posts

Posted 19 March 2010 - 07:58 PM

Wow...this is a very good engine! Might use it in my game. However when you drift and creates some skid marks they donīt dissapear. So how would you do to make them dissapear? The object_effect is quite too complicated for me so I donīt find a solution to this.

But anyways good example man! :)

Edited by Urbanturkin, 19 March 2010 - 07:59 PM.

  • 0

#28 DoctorKane

DoctorKane

    GMC Member

  • New Member
  • 1 posts

Posted 20 March 2010 - 06:01 AM


Hello and thank you for this amazing little game. I am having so much fun with it. Who doesnt like drifting. Awesome examples
and once again thanks!!!!!!!!!!!
  • 0

#29 babob

babob

    GMC Member

  • New Member
  • 1 posts

Posted 22 March 2010 - 05:17 PM

hohoho.. i like this engine!
make my dreem come true.. whaha hoho!

ewmm i'm new here. Just wanna ask, what do you mean give u credit? many people say like that if use stuff from them. can u give me an explanation please?? hehe :)
  • 0

#30 ntomic

ntomic

    GMC Member

  • New Member
  • 6 posts

Posted 23 March 2010 - 09:51 AM

Hi ,

Just found this engine and I really like it's simplicity.

I was wondering if anyone could help me with curved tracks? I've tried several curved images (for track boarders) using the same collision script but the car always gets stuck or eventually passes through them.

Thanks in advance

NTOMIC
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users