Vehicles and UFPS

Realistic Car Controller

First off, this is not a plug for Realistic Car Controller. I personally really like the asset by BoneCrackerGames, and it works really well with UFPS.
https://www.assetstore.unity3d.com/en/#!/content/16296
https://assetstore.unity3d.com/en/#!/content/16296

As you will see in my video, I’ve made edits to the Enter and Exit scripts that go on the Player and the Vehicle. I did this so that you can easily change the Input key code to match what you are using for UFPS (see Input Manager – default is the F key). I also “fixed” the script that comes with RCC so that it will only display the GUI when you are facing a “vehicle” based on what the vehicle tags are. There is an optional add to the script that goes on the vehicle to turn on/off a character model that you place inside the vehicle (for realism) which would also be a good spot to play an audio clip or add an animation, but I’m not doing all that.

For the RCCEnterExitCamera script – – –

//RedHawk Added the BELOW rows 9 to 20
[Tooltip("Change this to a KeyCode that you are not currently using, such as F. " +
"Ensure that the EnterExitCar script uses the same KeyCode.")]
public KeyCode interactionKeyCode=KeyCode.F;
[Tooltip("Enter the String for the Layer that your Vehicle is on. " +
"Otherwise, this will interact with all objects.")]
public string vehicleLayer="Vehicle";
int vehicleLayerInt;

void Start()
{
vehicleLayerInt=LayerMask.NameToLayer(vehicleLayer);
}
//RedHawk changed row 26
if (Physics.Raycast(transform.position, direction, out hit, maxRayDistance)&&hit.collider.gameObject.layer==vehicleLayerInt) {

//RedHawk changed row 28
if(Input.GetKeyDown(interactionKeyCode)) {

//RedHawk changed row 43
GUI.Label( new Rect(Screen.width - (Screen.width/1.7f),Screen.height - (Screen.height/1.4f),800,100),
"Press ''"+interactionKeyCode+"'' key to Enter/Exit.");

For the RCCEnterExitCar script – – –

//RedHawk Added Below - rows 14 to 20
[Tooltip("Change this to a KeyCode that you are not currently using, such as F. " +
"Ensure that the EnterExitCamera script uses the same KeyCode.")]
public KeyCode interactionKeyCode=KeyCode.F;
[Tooltip("Place your character in the car, assign it to the below, and when " +
"you are controlling car, the character will show up.")]
public GameObject characterInCar=null;

//RedHawk - changed row 31
if ((Input.GetKeyDown(interactionKeyCode)) && opened && !temp){

//RedHawk - inserted 2 rows after row 61 - optional to show the player in the vehicle
//RedHawk - for player to be displayed in vehicle
if(characterInCar!=null) //If this has been populated test
characterInCar.SetActive(true); //Set this active

//RedHawk - inserted 2 rows after row 77 - optional to show the player in the vehicle
//RedHawk - for player to be displayed in vehicle
if(characterInCar!=null) //If this has been populated test
characterInCar.SetActive(false); //Set this deactive

HeaderWP

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s