3D Tilt Racing (UPDATE self driving car)

This is a 3D (ok, 2.5D) racing game, where you tilt the iPad to steer left and right, and to speed up and slow down.

It has a track editor shown at the start of the video below, allowing you to push the track into a shape of your choice, then you can race on it (this technique could be used to create a sculpting app).

https://www.youtube.com/watch?v=jmB-6GFvNK0

I still need to provide the ability to save and load custom tracks, and scoring, and maybe things on the track to collect or avoid.

But the app is all about responsiveness.

Awesome! It would look great with some textures and lighting.

I’m also looking forward to seeing your tilt steering code. I’ve struggled with tilt steering in the past, because you only seem to be able to access the rotation rate, rather than an absolute value, so the “centre” of the wheel shifts if the user steers past the left or right wheel lock

I am simply using gravity, I will share code tomorrow

Looks great!

Wow, love it

Looks amazing @Ignatz. I think your track editor is very intuitive.

You could make the little people into billboards so they always face the camera (at least on the y-axis)

Thanks, @Simeon

I’m thinking of billboarding the people, but that means separating them individually from the side panels, so it’s quite a lot of work. There may be a better option.

I’ve updated it

https://www.youtube.com/watch?v=tUG_HSWODNU

The crowd is individually animated, there is a mini-map, and a rather crude car front end image that helps with steering. All the images are really placeholders.

I’m not going to finish this game for the competition, because there isn’t a lot of time, and that is all the boring work. Instead, I’m going to write up the interesting stuff in the game on my blog, then I’ll post the link here.

For those who want to try it as it stands now - code

some praise, 3D Tilt Racing

Out of curiosity, how does the track editor work at a high level? Is it a spline that you add control points to?

@Simeon - easier than that

It’s a fixed set of 100 points. When you touch the screen, it takes the direction and dots it with the directions of all the points, and distorts them more if they are close in angle. That’s all.

 for i=1,points do  --loop through track points
    local ti=track[i]:normalize() --get direction of this point
    local a=dn:dot(ti) --dot with touch direction
    if a>0 then --if on same side of track, then
        a=a^(16-Smoothness*3) --adjust for smoothness
         --then move point up or down its normal
        track[i]=ti*(dLen*a+track[i]:len()*(1-a))
    end
end 

beautiful
i remember the first car game in 2d “Atari Eduro” by Ruilov
a lot of work to create 3d car game in 60 fps on ipad air
I can not wait to see the buildings on the side of the road ^:)^ ^:)^

@yojimbo2000 - this is my tilt code

--speed is controlled by tilting forward and backward
speed=math.max(0,math.min(maxSpeed,speed+Gravity.y))
--turning left and right is controlled by tilting left and right
--this angle is in radians to avoid needing to convert for sin/cos
angle=angle+Gravity.x/100

This is literally all the controller code.

I can’t believe it never occurred to me to try the gravity variable for steering. X_X

Well done @Ignatz another class piece of work. I like the neat way you set draw to equal the function you want to use for rendering (ie managing wether your in the editor or in the game). The only thing I noticed is that if you tilt it too far forward then the orientation changes, I guess you could fix it to either LANDSCAPE_LEFT or LANDSCAPE_RIGHT.

@yojimbo2000 - whenever I’ve seen games that use the accelerometer to control movement it’s usual to have a calibration screen at the start of the game to define some initial reference point (ie hold device still for a couple of seconds) and then calculate distance from this point. Personally I’m not a fan of tilt based gaming but each to their own.

This competition was about responsiveness, which is why I used tilt

wrt redefining draw to different functions depending on the state of the game, well I can thank the forum for that. It’s a great approach.

I posted some comments on this project here

https://coolcodea.wordpress.com/2015/03/28/208-3d-racing-game-faq/

@Ignatz - for what it’s worth, when the voting opens your game is the one that will get my vote. I think out of all the entries I’ve seen so far it’s the most technically impressive and offers the greatest opportunity to learn new skills from.

Especially if it was all written in one week time.

No, it’s unfinished, so it can’t win, but I did it for fun