• 大小: 7.47MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-09-23
  • 语言: 其他
  • 标签: unity3d  c#  

资源简介

源码可使用unity打开,一个赛车游戏。

资源截图

代码片段和文件信息

/**
 * A simple car physics script using wheel colliders.
 * Jaap Kreijkamp jaap@ctrl-j.com.au
 *
 * orientation should be that front of car is in direction of
 * the ‘blue arrow‘ in Unity the roof should be in direction of
 * the green angle. Thus with rotation 0 0 0 adding 1 to Z
 * will move car 1m forward adding 1 to Y will move car 1m
 * upward. The wheels should be children of the car object this
 * script is added to and connected to the wheelFL wheelFR ...
 * variables.
 *
 * Please modify script and do whatever you like with it
 * in it‘s current state it should give a working car
 * but by no means perfect (or even close) behavior.
 * It‘s my first attempt and don‘t really need in my current
 * project so haven‘t put too much effort into it to perfect
 * it. As often people are looking for help to getting
 * a car working with wheel colliders I‘d appreciate when
 * improvements are posted back on the unity forums.
 *
 * Lastly thanks to all the people helping me on forums (especially
 * the order of initialisation problem and other example
 * code that helped me much in learning how to do stuff like
 * this).
 */

using UnityEngine;
using System.Collections;

// used to indicate if car is frontwheeldrive backwheeldrive or 4wheeldrive
// also (mis)used to indicate if a wheel is a front wheel or a back wheel
public enum JWheelType {
Front = 1
Back = 2
All = 3
}


public class JCar : MonoBehaviour {

// if connected the controls will block if object not active
// (for example steer only if car camera is active).
public Gameobject checkForActive;

// if set car records position accel ... data every time
// handle motor is called.
public JRecordRoute recordRoute;

// returns current speed in Km/H
public float CurrentSpeed {
get { return rigidbody.velocity.magnitude * 3.6f; }
}

public int CurrentGear {
get { return currentGear; }
}

public float MotorRPM {
get { return motorRPM; }
}

public bool MotorRunning {
get { return audioSource.isPlaying; }
}

public float TotalDistance {
get { return totaldist; }
}

public Transform wheelFR; // connect to Front Right Wheel transform
public Transform wheelFL; // connect to Front Left Wheel transform
public Transform wheelBR; // connect to Back Right Wheel transform
public Transform wheelBL; // connect to Back Left Wheel transform

// power curves (power1 is for gear 1 and reverse!)
// horizontal axis is RPM
// vertical axis is power where 5000f equals to 100%
// (you can go over 5000f if you want but for easier tuning it‘s probably
//  better to adjust the torque parameter and keep the curve below 5000f.)
// the default values are totally useless so you have to edit the curves
// you can do this by adding CurveEditor.cs and ResponseCurveEditor.cs to
// your project (in Editor directory of JCar or in the Animation-API example).
// the best way to set curves is steep increase with top at 2000RPM then
// slow decrease back to 0 at h

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2019-02-26 18:13  Unity3D开发的简单赛车游戏\
     目录           0  2019-02-26 18:21  Unity3D开发的简单赛车游戏\greenCar\
     文件        6148  2008-08-21 09:20  Unity3D开发的简单赛车游戏\greenCar\.DS_Store
     目录           0  2019-02-26 18:15  Unity3D开发的简单赛车游戏\greenCar\Assets\
     文件        6148  2008-08-14 15:32  Unity3D开发的简单赛车游戏\greenCar\Assets\.DS_Store
     目录           0  2019-02-26 18:15  Unity3D开发的简单赛车游戏\greenCar\Assets\Car\
     文件        6148  2008-08-17 15:58  Unity3D开发的简单赛车游戏\greenCar\Assets\Car\.DS_Store
     文件       28689  2008-08-20 13:32  Unity3D开发的简单赛车游戏\greenCar\Assets\Car\Car.jas
     文件        2035  2019-02-26 18:15  Unity3D开发的简单赛车游戏\greenCar\Assets\Car\Car.jas.meta
     文件      107411  2008-08-12 12:17  Unity3D开发的简单赛车游戏\greenCar\Assets\Car\Car.png
     文件        1430  2019-02-26 18:15  Unity3D开发的简单赛车游戏\greenCar\Assets\Car\Car.png.meta
     文件        7299  2008-08-19 21:33  Unity3D开发的简单赛车游戏\greenCar\Assets\Car\DirectionDisplay.jas
     文件        1874  2019-02-26 18:15  Unity3D开发的简单赛车游戏\greenCar\Assets\Car\DirectionDisplay.jas.meta
     目录           0  2019-02-26 18:15  Unity3D开发的简单赛车游戏\greenCar\Assets\Car\Materials\
     文件        3654  2008-08-14 15:29  Unity3D开发的简单赛车游戏\greenCar\Assets\Car\Materials\Car Black Color.mat
     文件         161  2019-02-26 18:15  Unity3D开发的简单赛车游戏\greenCar\Assets\Car\Materials\Car Black Color.mat.meta
     文件        3727  2008-08-14 16:53  Unity3D开发的简单赛车游戏\greenCar\Assets\Car\Materials\Car.mat
     文件         161  2019-02-26 18:15  Unity3D开发的简单赛车游戏\greenCar\Assets\Car\Materials\Car.mat.meta
     文件        3654  2008-08-14 20:36  Unity3D开发的简单赛车游戏\greenCar\Assets\Car\Materials\GhostCar Black Color.mat
     文件         161  2019-02-26 18:15  Unity3D开发的简单赛车游戏\greenCar\Assets\Car\Materials\GhostCar Black Color.mat.meta
     文件        3735  2008-08-14 16:55  Unity3D开发的简单赛车游戏\greenCar\Assets\Car\Materials\GhostCar.mat
     文件         161  2019-02-26 18:15  Unity3D开发的简单赛车游戏\greenCar\Assets\Car\Materials\GhostCar.mat.meta
     文件        3646  2008-08-20 14:32  Unity3D开发的简单赛车游戏\greenCar\Assets\Car\Materials\car-b h 01.mat
     文件         161  2019-02-26 18:15  Unity3D开发的简单赛车游戏\greenCar\Assets\Car\Materials\car-b h 01.mat.meta
     文件        3809  2008-08-12 16:14  Unity3D开发的简单赛车游戏\greenCar\Assets\Car\Materials\dials.mat
     文件         161  2019-02-26 18:15  Unity3D开发的简单赛车游戏\greenCar\Assets\Car\Materials\dials.mat.meta
     文件        3646  2008-08-12 16:15  Unity3D开发的简单赛车游戏\greenCar\Assets\Car\Materials\speedometer.mat
     文件         161  2019-02-26 18:15  Unity3D开发的简单赛车游戏\greenCar\Assets\Car\Materials\speedometer.mat.meta
     文件         150  2019-02-26 18:15  Unity3D开发的简单赛车游戏\greenCar\Assets\Car\Materials.meta
     文件       48106  2008-08-19 14:03  Unity3D开发的简单赛车游戏\greenCar\Assets\Car\RPM.jas
     文件        1948  2019-02-26 18:15  Unity3D开发的简单赛车游戏\greenCar\Assets\Car\RPM.jas.meta
............此处省略1016个文件信息

评论

共有 条评论