Share your repls and programming experiences

← Back to all posts
3D Vehicle Physics Game!
tussiez (1499)

3D Car Physics Demo

Yet another physics demo..

I wanted to try writing a working 3D physics-based game, and this is as far as I got.

Currently working on a server physics engine (less lag!), stay tuned for that :D

Features

  • 3D physics!
  • Vehicle with realistic suspension
  • Terrain with basic obstacles and interactive objects

Although this is a relatively simple game, I spent countless hours trying to fix Physijs, as this library is over 5 years old and no longer works correctly with THREE, unfortunately :(
There is also no documentation on the vehicle physics itself, so I used Physijs' vehicle example.

You can use the vehicle generator I wrote for this game. If you measure by lines of code, this is relatively short, but helps a lot in the end.

Bugs

Sometimes you can get one of your wheels stuck inside the ground, since there is no physics body on the wheels (it appears to be a particle, so it can get stuck inside the thin terrain).
Press V to flip your vehicle.

The way that forces are applied to the wheels makes it that you will constantly accelerate, regardless if you are pressing W or not. There is no real way to maintain speed, unless I write a cruise control-style system (can only apply engine force). For some reason, setting engine force to 0 forces the car to brake instead of slowly losing speed. Eventually, I'll find a solution to this.

Controls

W, A, S, D moves the car, or arrow keys
Click and drag to look around.
Got stuck? Press V to flip.
If you want to go really fast, hold Q.

Enjoy!

PLAY PhysicsAgain

Not working?

Try the following:

  • Don't use a school computer
  • Disable your adblocker
  • Use Chrome

EDIT: Plz! Stop upvoting this! Has more updoots than SortaCraft now

Comments
hotnewtop
OldWizard209 (1091)

First thing I saw was this:

VEGETEABLES!!!

nah man I m out

JK lol, noice game with noicer physocs

Wilke000 (625)

WHY DOES THIS HAVE SOOOO MANY UPVOTES, AND ONLY HAVE TWO REPLYS!!!????? @OldWizard209

OldWizard209 (1091)

bruh @Wilke000 , IDK why, maybe people like the comment, so they just upvote. Doesn't mean that if you upvote, youhave to comment.....

Wilke000 (625)

Maybe @OldWizard209... I have said that before so...

[deleted]

@OldWizard209 the grass is a picture

firefish (992)

WHY DOES THIS HAVE SOOOO MANY UPVOTES, AND ONLY HAVE TWO REPLYS!!!????? @OldWizard209

@Wilke000 wat

Wilke000 (625)

Yeah, well @firefish.................. It had 2 comments........... so........ yeah.......

firefish (992)

@Wilke000 oh i thought it said repls not replies oh dummy me

Wilke000 (625)

@firefish:

oh dummy me
Hmm.... mmm, hm.... hmmmmmmmmmmmm
Ok, I think that you are overreacting, you are a good coder.

Rebelthunder (1)

@tussiez I think you should make this 4x4 because this keeps flipping over whenever I hold boost.

Rebelthunder956 (1)

@tussiez is it? cause it works better in reverse, so that's making me think that it's rear wheel drive.

Rebelthunder956 (1)

also, this is my alt account.

tussiez (1499)

@Rebelthunder956 Huh.. must be the physics engine

OldWizard209 (1091)

@Rebelthunder956 @tussiez @adilskillz and @Wilke000 can you guys stop replying to this thread. You are clogging my notifications and my e-mail...

tussiez (1499)

@OldWizard209 Yikes! Sorry, my email is spammed too

Wilke000 (625)

Oh lol ok @OldWizard209 I know how it feels...........

OldWizard209 (1091)

Yeah but it still continues... @Wilke000

[deleted]

Because he's a god at coding.

ninjaread99 (19)

whoever said i would love holding v... you were... not wrong...

Rebelthunder (1)

@tussiez could you also try to change the code a bit so that u can move when flying with "v"?

tussiez (1499)

@Rebelthunder It was originally intended to flip :D

LaneMartin (69)

Let's pay respects to the people who play this game without a mouse (touchpad users I understand your suffering)

videogamehover (4)

mum, can we get forza?
no we have forza at home
forza at home:

(its really good btw, keep up the great work!)

tussiez (1499)

@videogamehover
Hah, don't make me laugh in class :D
Thanks!

AndrewMarkarian (19)

YAY! (Usually happens when there is a server involved)

AndrewMarkarian (19)

@tussiez You can always tell if it is a good game from the code and reviews.

AndrewMarkarian (19)

Now I know why I keep getting a cycle a day.

Bookie0 (5956)

Oh...oh no..uh oh..whoops.

brucelk (1)

if you spam v after you drive off the edge and spawn again then you can slowly glitch upwards.

OldWizard209 (1091)

NGL, this seems to be an accurate representation of what the Mars Rovers will being doing secretly out there...

Grifano (3)

O, you’ve used a more than one h1, for this project it’s not important, but in a future you can’t actually use more than one h1 on a page 😉

tussiez (1499)

@Grifano Where did you learn that? You can use any many <h1>s as you need. There is no limit to how many of an element you can use on a page. In this case, it makes it easier to create big text. This is just like saying <div>s can only be used ten times, lol

tussiez (1499)

@Grifano Not good practice, not that anything will break

sojs (295)

Yes. Another problem is with SEO optimization but this should be fine. I usually do h6s with a class of h1 wich
looks excactly like and h1, but does not act like one. Im not excactly sure that a screenready would work with this site tho, its all [email protected]

xxpertHacker (865)

@tussiez Well you can use more than one html tag too:

<html>
  <html>
    ...
  </html>
</html>
<html>
  ...
</html>
xxpertHacker (865)

@tussiez Lol, the empty Repl has it's head in it's body.

tussiez (1499)

@xxpertHacker Chrome does this automatically iirc, so I decided to

xxpertHacker (865)

@tussiez Wdym Chrome does this automatically?

Any references?

tussiez (1499)

@xxpertHacker Put <head> outside of <body> and look in Inspect

xxpertHacker (865)

@tussiez Yeah no, Chrome just attempts to correct your bad HTML.

<head> outside of <body>:

html
  head
  body

<head> in <body>:

html
  body
    head

But even if Chromium did it, you wouldn't be considering other browsers, such as Firefox, or Safari :/

tussiez (1499)

@xxpertHacker No idea, it was just a habit I developed after seeing Chrome put it in(???) somehow

firefish (992)

@sojs Ah yes, SEO optimisation. Search Engine Optimisation Optimisation.

firefish (992)

@tussiez Well, this is the only reason why Ace is a good thing to use.

firefish (992)

@tussiez
SEO Optimisation is Search Engine Optimisation Optimisation.
PIN Number is Personal Identification Number Number.
You are repeating the last word in the acronym.

sojs (295)

ahh yes. the real secret to getting higher up on search engine results. @firefish

tussiez (1499)

@sojs Optimize the optimizer.

tehgingergod (4)

@tussiez wouldn't that make you...
Search Engine Optimization Optimization Optimizer

ErinPark5 (3)

Hey:) You did good.... Nice!

ErinPark5 (3)

@tussiez Of course! If you want more please contact me for more games. If you want directions to make awesome/new games ask me too.. Thanks a lot:)

Baconman321 (1058)

Suddenly I realize.... this looks like Jailbreak keybindings!!!

:sus:

tussiez (1499)

@Baconman321
Dang it. Ya got me again. >:( >:(
I did use Jailbreak keybinds..

Baconman321 (1058)

@tussiez Space would be better for break (it's more well known), as well as shift for the boost.

Vehicle simulator has the above mentioned keybindings for their game.

Also...

wanna work on sortacraft? (IK it's a bad post to ask on but whatever)

tussiez (1499)

@Baconman321
1. Meh, it's just a demo, this can be easily changed (or become an option!) in the future

  1. Hmm
Unclyscam123 (3)

people save your updotes for sortacraft 2!!!

cgcgcgcgcg (1)

it could have a better car but apart from that it is a very good game

PYTHORE3605 (104)

Dang it, you cant drift... It flips your car.

Wilke000 (625)

ARROW SUPPORT PLEASE!!!! WSAD IS SOOOOOOOOO HARD FOR ME!!!!!!

PLS DO IT
firefish (992)

@Wilke000 oh no i revealed the true power of the accented é... you saw nothing

Wilke000 (625)

@firefish sus

@firefish has been ejected (Imposter)

kwe (19)

mm myes epic car

eleazarfolabit (1)

This is really cool hope to see a full version

LukeWright (114)

This reminds me of robocraft back when it was good. also, why are the brakes on the front wheel instead of the back?

tussiez (1499)

@LukeWright It flips too hard when I set it to the back wheels

ahmedaiad (0)

when i press w, i gradually move left in a 360 turn, maybe u should check the function code, other then that, its really good and its clear that you put some work into it

BenjaminWatts1 (1)

lol the ball still on the platform.

Safariminer (1)

By the way, if you spam V, you can fly!

ReyesP (24)

I almost forgot about SortaCraft since this thing was so good! I'm not saying SortaCraft isn't good, but this thing is just way better!

tussiez (1499)

@ReyesP Ah, that's why it has ..
uhh..
hmm..
330 upvotes?!

BenjaminWatts1 (1)

It really good but the car flips too easily and also you can't make it up the big ramp no matter how hard you try. But Its really good. Keep up the great work. I'm looking forward to your next one.

tussiez (1499)

@BenjaminWatts1 Thanks! It is possible to go up the big ramp, :D

BenjaminWatts1 (1)

@tussiez I just figured that out but I really want to run off the ramp at full speed lol.

jeweledfox (6)

Really cool! Also, you can fly by holding V :)