Snowmobile script (being able to drive it)

Okay, apparently I’ve been working on a “Snowmobile Simulator”, creating maps, creating my snowmobiles for weeks. I actually found this car tutorial on the asset store, I’ve tried by changing the scripts in order to make it work for my project, I’ve never managed to get that working. If you look at other games like Modern Warfare 2, whenever you’re escaping the cliff hanger, you do make your way to the extraction point with a snowmobile, this actually gave me an idea making my own snowmobile game on Unity. I have my colliders ready up, just need the scripts in order to make it work.

Also, before I end it here, here’s a few screenshots of my snowmobile:

[19340-unity+2013-12-14+15-43-17-95.png|19340]
[19341-unity+2013-12-14+15-44-35-96.png|19341]

I know this sounds complicated, but I would really appreciate it if you guys could make me a script for my snowmobile :slight_smile:

Thanks!

2 Answers

2

I would make it a 3 wheeled car that looks like a snowmobile. 2wheels really close together at teh back and 1 for each ski at the front. And add some white particicles to the treds

And to start I would follow a car tutorial.

I've checked their channel, is it the Car AI tutorial or is it the "How to make a Car game"?

How to make a car game. Then the other for bots if you want

I understand you Kilo, but I'm not just going to be driving my snowmobile for all the time, here's a few other things I might add during the future: - NPCs (bots that follow you or goes anywhere) - Different game mode types - Maybe multiplayer (I'm very far from that now, might be added) In fact, I know a few things in scripts. Still far ahead to know all the commands, maybe I'll be creating my own scripts with the new Unity page (Learn) and might be able to get around my project.

Okay, I've tried the tutorial. My snowmobile makes a "wheelie" whenever I'm going backwards. It's also slow when I'm going forward, I think this script isn't for a snowmobile at all. Is there anyway you could actually help me with this? Or should I contact the guy that made the tutorial?

So apparently I've changed the wheel colliders to box colliders, now I'm getting this error: Assets/3D Models/Snowmobiles/DarkRed/Snowmobile Scripts/Snowmobile.js(19,9): BCE0019: 'steerAngle' is not a member of 'UnityEngine.BoxCollider'. Should I post the script that I've edited? I had no choice to change it.

Add a rigid body to your snow mobile
Set Rigid body drag settings to 1
add this script to your snow mobile

using UnityEngine;
using System.Collections;
 
public class SnowMobileController : MonoBehaviour {
        public float force = 20;
 
        // Use this for initialization
        void Start () {
       
        }
       
        // Update is called once per frame
        void Update () {
// You may have to change rigidbody.AddForce(Vector3.back*force) to the opposite so vector3.back will end up vector3.forward
                if(Input.GetKeyDown("s")){
                rigidbody.AddForce(Vector3.back*force);
                        if(Input.GetKeyDown("w")){
                                rigidbody.AddForce(Vector3.forward*force);
                        }
                                if(Input.GetKeyDown("a")){
                                        rigidbody.AddForce(Vector3.right*force);
                        }
                                        if(Input.GetKeyDown("d")){
                                                rigidbody.AddForce(Vector3.left*force);
        }
                }}}

if you want animations will have to add animation.play under the keystroke for animations, ex.

 if(Input.GetKeyDown("s")){
  rigidbody.AddForce(Vector3.back*force);
        animation.Play("snowmobileforward");

Or if you want the wheel of the snowmobile to rotate
add

public gameobject Wheel1;
public gameobject Wheel2;
public gameobject Wheel3;

to the declaration of the script
&

if(Input.GetKeyDown("s")){
				rigidbody.AddForce(Vector3.back*force);
				Wheel1.transform.Rotate(Vector3.Forward * Time.deltaTime);
				Wheel2.transform.Rotate(Vector3.Forward * Time.deltaTime);
				Wheel3.transform.Rotate(Vector3.Forward * Time.deltaTime);
			}

Umm... My snowmobile isn't moving at all, except when I press the "S" key, it only shakes and won't move.

adjust the force on the script to like 2000 just too see if it works, also check there's no colliders blocking it, you may have to change Vector3.back to like Vector3.up, depends what rotation your model is on. make sure there's a rigid body connected to it tou.