Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Ballistics physics - How is it possible!?!?

Discussion in 'Scripting' started by MrRandomFella, Apr 8, 2014.

  1. MrRandomFella

    MrRandomFella

    Joined:
    Nov 24, 2013
    Posts:
    16
    Hi everyone.

    If anyone would like to know, I am creating a game similar to one of my favourite video games of all time, Ballistics (obviously, no one knows what this is). Ballistics was a futuristic racing game released in 2001 on PC and arcades. The game only took 6 months to create, so I'm guessing it wasn't that hard to make??

    I have tried many different methods of replicating this gravity defying gameplay, but nothing works. I have tried putting an empty gameobject in the dead centre of a tunnel and attaching a ship to the bottom. So that whenever the gameobject rotates, the ship looks like it's driving on the walls. This is ok, If I wanted to make an endless straight boring tunnel game, I want to have a tunnel with twists and turns that lead the player back to the starting line, and tunnels that lead down under the ocean and into space and through incredible scenery!! I just don't know how?

    I have tried splines but the only script that works well, doesn't allow me to freely accelerate or rotate on the z axis (which is obviously what I need).

    For anyone that doesn't know about ballistics (fastest game in the world) here's a video :


    So, I'm at a dead end. Can anyone help?
     
  2. bigmisterb

    bigmisterb

    Joined:
    Nov 6, 2010
    Posts:
    4,221
    Physics are the way to go. turn off gravity and add gravity to your ship in -transform.up direction. (at 9.8f force)

    This will give you the "stick to the walls" feeling.

    You could increase the gravity to allow the player to do inverted turns, but at that speed, you will probably be sucked to a wall.

    Another method is to simply use -transform.up raycasts and get the position on the wall from this. This would "stick to the wall" but you would have to program things like jumps and stuff rather than let the physics engine take care of it.

    One trick is to use physics and code. It can be a sticky widget.
     
  3. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,716
    Splines are the way to go here... I guess you didn't get a good spline script.

    I'm working on an endless runner where you can run on wall and ceiling, and we had to write our own splines. I would put a spline in the middle of the "pipe" and do a projection off it. Looks to me from your video that all the "pipe" has the same diameter.
     
  4. MrRandomFella

    MrRandomFella

    Joined:
    Nov 24, 2013
    Posts:
    16
    I found the spline controller on the wiki, It works really well.

    Just not how I want it to :mad:
     
  5. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,716
    How so?
     
  6. MrRandomFella

    MrRandomFella

    Joined:
    Nov 24, 2013
    Posts:
    16
    It automatically moves along the spline path, I need it to accelerate along the path when the player presses the Z key. :/
     
  7. MrRandomFella

    MrRandomFella

    Joined:
    Nov 24, 2013
    Posts:
    16
    Ok, here is an absolutely ridiculous sounding idea! What if, the rotating object placed in the center of the tunnel is attached to a gameobject with a box collider, then has a script applied to it that applies force from each face to keep it centered within any part of the tunnel. (meaning that force is applied outward from all angles of the cube which keeps it exactly center and able to deal with bends and turns). This probably makes no sense whatsoever but I thought that this idea may actually work.

    If this does make sense to anyone then please, post a reply on how I would write a script like this!
    (I really want to see this project kick off!)
     
  8. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,716
    Well, that's what I said... Wrong spline script. You need a script that has method that returns a point along the spline based on a distance from the first node.