Commit 8da55d1e authored by Danial KordModanlou's avatar Danial KordModanlou

some changes

parent 18810d82
namespace TurnTheGameOn.IKDriver
using System;
namespace TurnTheGameOn.IKDriver
{
using UnityEngine;
using UnityEngine.UI;
......@@ -16,6 +18,8 @@
public KeyCode d5 = KeyCode.Joystick1Button12;
public KeyCode d6 = KeyCode.Joystick1Button13;
*/
#region Public Variables
public IKD_VehicleInput vehicleInput;
......@@ -145,6 +149,7 @@
#region Utility Methods
private void CapSpeed()
{
speed = rbody.velocity.magnitude;
float speedometerMultiplier = speedType == SpeedType.MPH ? 2.23693629f : speedType == SpeedType.KPH ? 3.6f : 0f;
speed *= speedometerMultiplier;
......@@ -167,9 +172,14 @@
public void setGear(float kelazh)
{
if (true)
if (kelazh >= 0.7f)
{
if (Input.GetKey(KeyCode.JoystickButton8))
if (Input.GetKeyUp(KeyCode.JoystickButton8) || Input.GetKeyUp(KeyCode.JoystickButton9) || Input.GetKeyUp(KeyCode.JoystickButton10)
|| Input.GetKeyUp(KeyCode.JoystickButton11) || Input.GetKeyUp(KeyCode.JoystickButton12) || Input.GetKeyUp(KeyCode.JoystickButton13))
{
currentGear = 0;
}
else if (Input.GetKey(KeyCode.JoystickButton8))
{
currentGear = 1;
}
......@@ -193,10 +203,6 @@
{
currentGear = -1;
}
else
{
currentGear = 0;
}
//Debug.Log("curent : "+currentGear);
}
}
......@@ -227,7 +233,7 @@
}
else
{
//setGear(kelazh);
setGear(kelazh);
}
}
......@@ -278,6 +284,8 @@
}
public void Move(float clazh,float steering, float accel, float footbrake, float handbrake){
setPedalSoundSystem(accel);
for (int i = 0; i < 4; i++){
Quaternion quat;
......@@ -316,6 +324,9 @@
}
SteerHelper();
ApplyDrive(accel, footbrake);
//Set the handbrake, Assuming that wheels 2 and 3 are the rear wheels.
if (handbrake > 0f) {
var hbTorque = handbrake * maxHandbrakeTorque;
......@@ -330,8 +341,13 @@
if (currentGear == -1)
{
Debug.Log("aghab");
transform.Translate(transform.forward * -1 * accel * Time.fixedDeltaTime*2);
//ApplyDrive(0, -1);
//transform.Rotate(0,0.1f * accel * Mathf.Lerp(-90,90,(steering + 1)/2)*Time.fixedDeltaTime,0);
transform.position += transform.forward * -1 * accel * Time.fixedDeltaTime*2;
rbody.velocity = Vector3.zero;
return;
//rbody.AddForce(-transform.forward*-1 * accel * Time.fixedDeltaTime*20000);
//return;
}
rbody.AddForce(-transform.up * downforce * rbody.velocity.magnitude); // Apply down force, used to add more grip in relation to speed
......@@ -445,6 +461,7 @@
{
if (currentGear == -1) // reverse
{
//CancelInvoke ("ResetGearCheck");
if (speed < topSpeedReverse) Reverse (footbrake);
if (accel > 0) ApplyBrake (accel);
}
......
......@@ -133,7 +133,7 @@ namespace TurnTheGameOn.IKDriver
}
else //setupd joystic
{
vehicleController.setGear(cluch);
//vehicleController.setGear(cluch);
}
}
else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment