satisfied with controller now Before new UI

Single-Player
Ali Sharoz 1 month ago
parent 55f2eec9a0
commit e145dcec40

@ -20507,7 +20507,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: c7b8a4db074ebd44980c8e8f18ff5a82, type: 3}
m_Name:
m_EditorClassIdentifier:
_leadOffset: 35
_leadOffset: 25
_leadMultiplier: 0.25
_sideOffset: 0
waypointsCircuit: {fileID: 0}

@ -61,7 +61,7 @@ Material:
m_Offset: {x: 0, y: 0}
m_Ints: []
m_Floats:
- _BlurStrength: 0.05932593
- _BlurStrength: 0.05000001
- _BumpScale: 1
- _Cutoff: 0.5
- _DetailNormalMapScale: 1

@ -8,4 +8,8 @@ public class HomeScreenUI : MonoBehaviour
{
SceneManager.LoadScene("Gameplay");
}
public void ApplicationQuitter()
{
Application.Quit();
}
}

@ -7,7 +7,7 @@ PhysicMaterial:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Friction
dynamicFriction: 0.016947329
dynamicFriction: 0.068020746
staticFriction: 1
bounciness: 0
frictionCombine: 3

File diff suppressed because it is too large Load Diff

@ -34,9 +34,10 @@ public class SkidMarks : MonoBehaviour
if (_attachedController.Grounded)
{
//_tireTrail.emitting = Mathf.Abs(_attachedController.LocalVelocity.x) > 10f;
_tireTrail.emitting =
Mathf.Abs(_attachedController.LocalVelocity.x) > 25f &&
_attachedController.CurrentSpeed > 70f;
_tireTrail.emitting = Mathf.Abs(_attachedController.LocalVelocity.x) > 25f && _attachedController.CurrentSpeed > 70f;
//_tireTrail.emitting =
//Mathf.Abs(_attachedController.LocalVelocity.x) > 5f &&
//_attachedController.CurrentSpeed > 20f;
}
else
{

@ -147,6 +147,34 @@ public class VehicleController : MonoBehaviour
HandleMovement();
}
//private void ProcessInputs()
//{
// if (isAIControlled)
// {
// Vector3 targetPoint = targetTracker.TargetPos;
// targetPoint.y = transform.position.y;
// Vector3 directionToTarget = (targetPoint - transform.position).normalized;
// float angleToTarget = Vector3.Angle(transform.forward, directionToTarget);
// float distanceToTarget = Vector3.Distance(transform.position, targetPoint);
// if (distanceToTarget < targetStoppingDistance)
// inputVertical = 0f;
// else if (angleToTarget > 60f)
// inputVertical = 0.3f;
// else if (angleToTarget > 30f)
// inputVertical = 0.6f;
// else
// inputVertical = 0.95f;
// inputHorizontal = 0f;
// }
// else
// {
// inputVertical = CnInputManager.GetAxis("Vertical");
// inputHorizontal = CnInputManager.GetAxis("Horizontal");
// }
//}
private void ProcessInputs()
{
if (isAIControlled)
@ -171,8 +199,9 @@ public class VehicleController : MonoBehaviour
}
else
{
inputVertical = CnInputManager.GetAxis("Vertical");
inputHorizontal = CnInputManager.GetAxis("Horizontal");
// 👇 Dampen steering sensitivity
inputHorizontal = Mathf.Clamp(CnInputManager.GetAxis("Horizontal") * 0.85f, -1f, 1f);
inputVertical = Mathf.Clamp(CnInputManager.GetAxis("Vertical"), -1f, 1f);
}
}
@ -316,6 +345,7 @@ public class VehicleController : MonoBehaviour
{
velocityLocal = vehicleRigidbody.transform.InverseTransformDirection(vehicleRigidbody.velocity);
// Apply lateral friction
wheelFrictionMaterial.dynamicFriction = _frictionCurve.Evaluate(Mathf.Abs(velocityLocal.x / 100f));
steeringMultiplier = _turnCurve.Evaluate(velocityLocal.magnitude / maxSpeed);
@ -323,14 +353,30 @@ public class VehicleController : MonoBehaviour
{
steeringSign = Mathf.Sign(velocityLocal.z);
if (Mathf.Abs(accelerationInput) > 0.1f)
vehicleRigidbody.AddTorque(Vector3.up * (steeringAI * steeringSign * steeringSensitivity * 100f * steeringMultiplier /** steeringFactor*/));
// Steering torque
if (inputVertical > 0.1f || velocityLocal.z > 1f)
vehicleRigidbody.AddTorque(Vector3.up * (steeringAI * steeringSign * steeringSensitivity * 100f * steeringMultiplier));
else if (inputVertical < -0.1f || velocityLocal.z < -1f)
vehicleRigidbody.AddTorque(Vector3.up * (steeringAI * steeringSign * steeringSensitivity * 100f * steeringMultiplier));
if (Mathf.Abs(accelerationInput) > 0.1f)
sphereRigidbody.velocity = Vector3.Lerp(sphereRigidbody.velocity, vehicleRigidbody.transform.forward * (accelerationInput * maxSpeed), accelerationForce / 10f * Time.fixedDeltaTime);
// Brake logic (if needed)
// You can add: sphereRigidbody.constraints = brakeInput > 0.1f ? RigidbodyConstraints.FreezeRotationX : RigidbodyConstraints.None;
// Velocity alignment using Lerp (matches reference)
if (Mathf.Abs(inputVertical) > 0.1f && brakeInput < 0.1f)
{
Vector3 targetVelocity = vehicleRigidbody.transform.forward * (inputVertical * maxSpeed);
sphereRigidbody.velocity = Vector3.Lerp(
sphereRigidbody.velocity,
targetVelocity,
accelerationForce / 10f * Time.fixedDeltaTime
);
}
// Downforce for grip
sphereRigidbody.AddForce(-transform.up * (downforce * sphereRigidbody.mass));
// Align car with surface
vehicleRigidbody.MoveRotation(
Quaternion.Slerp(
vehicleRigidbody.rotation,
@ -341,17 +387,61 @@ public class VehicleController : MonoBehaviour
}
else
{
// Optional: allow air control
if (allowAirControl)
vehicleRigidbody.AddTorque(Vector3.up * (steeringAI * steeringSensitivity * 100f * steeringMultiplier /** steeringFactor*/));
{
vehicleRigidbody.AddTorque(Vector3.up * (steeringAI * steeringSensitivity * 100f * steeringMultiplier));
}
// Apply velocity while airborne
sphereRigidbody.velocity = Vector3.Lerp(
sphereRigidbody.velocity,
(vehicleRigidbody.transform.forward * (accelerationInput * maxSpeed)) + Vector3.down * (gravityForce * 9.8f),
(accelerationForce / 25f) * Time.deltaTime
vehicleRigidbody.transform.forward * (inputVertical * maxSpeed) + Vector3.down * gravityForce * 9.8f,
accelerationForce / 25f * Time.deltaTime
);
}
}
//private void HandleMovement()
//private void HandleMovement() //second
//{
// velocityLocal = vehicleRigidbody.transform.InverseTransformDirection(vehicleRigidbody.velocity);
// wheelFrictionMaterial.dynamicFriction = _frictionCurve.Evaluate(Mathf.Abs(velocityLocal.x / 100f));
// steeringMultiplier = _turnCurve.Evaluate(velocityLocal.magnitude / maxSpeed);
// if (Grounded)
// {
// steeringSign = Mathf.Sign(velocityLocal.z);
// if (Mathf.Abs(accelerationInput) > 0.1f)
// vehicleRigidbody.AddTorque(Vector3.up * (steeringAI * steeringSign * steeringSensitivity * 100f * steeringMultiplier /** steeringFactor*/));
// if (Mathf.Abs(accelerationInput) > 0.1f)
// sphereRigidbody.velocity = Vector3.Lerp(sphereRigidbody.velocity, vehicleRigidbody.transform.forward * (accelerationInput * maxSpeed), accelerationForce / 10f * Time.fixedDeltaTime);
// sphereRigidbody.AddForce(-transform.up * (downforce * sphereRigidbody.mass));
// vehicleRigidbody.MoveRotation(
// Quaternion.Slerp(
// vehicleRigidbody.rotation,
// Quaternion.FromToRotation(vehicleRigidbody.transform.up, surfaceHit.normal) * vehicleRigidbody.transform.rotation,
// 0.12f
// )
// );
// }
// else
// {
// if (allowAirControl)
// vehicleRigidbody.AddTorque(Vector3.up * (steeringAI * steeringSensitivity * 100f * steeringMultiplier /** steeringFactor*/));
// sphereRigidbody.velocity = Vector3.Lerp(
// sphereRigidbody.velocity,
// (vehicleRigidbody.transform.forward * (accelerationInput * maxSpeed)) + Vector3.down * (gravityForce * 9.8f),
// (accelerationForce / 25f) * Time.deltaTime
// );
// }
//}
//private void HandleMovement() //original
//{
// velocityLocal = vehicleRigidbody.transform.InverseTransformDirection(vehicleRigidbody.velocity);

Loading…
Cancel
Save