Passenger: no automatic seat when getting in on the driver's side
Getting in on the driver's side moves the head past the passenger seat while the game puts the player into the driver's seat. Auto-boarding now only triggers from the passenger side (head on the seat's side, not further inside than the seat), not while the game controls the player (CharacterController off or parented to a vehicle) and not within 4 s after driving. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+13
-1
@@ -37,7 +37,8 @@ namespace MSCO
|
||||
// Fahrerkopf je Fahrzeug (lokal), aus DriverHeadPivot - null = nicht gefunden
|
||||
readonly Dictionary<Rigidbody, Vector3?> driverHeads = new Dictionary<Rigidbody, Vector3?>();
|
||||
|
||||
float nextAutoCheck, dwellStart = -1f;
|
||||
float nextAutoCheck, dwellStart = -1f, lastDriving = -100f;
|
||||
const float AfterDrivingPause = 4f; // nach dem Fahren (Ein-/Aussteigen am Fahrersitz) nicht automatisch
|
||||
SyncedBody dwellVehicle;
|
||||
bool autoArmed = true;
|
||||
Vector3 lastExitSeat;
|
||||
@@ -85,7 +86,14 @@ namespace MSCO
|
||||
/// </summary>
|
||||
public string AutoUpdate(Transform player, Camera cam, ObjectSync objects, IDictionary<int, PlayerInfo> players)
|
||||
{
|
||||
if (objects.IsDriving) lastDriving = Time.time;
|
||||
if (IsRiding || cam == null || player == null || objects.IsDriving) { dwellStart = -1f; return null; }
|
||||
// Steigt man auf der Fahrerseite ein, setzt das Spiel einen über die Sitze auf den Fahrersitz - dabei kommt der
|
||||
// Kopf kurz am Beifahrersitz vorbei. Solange das Spiel die Steuerung hat (CharacterController aus, Spieler an
|
||||
// ein Fahrzeug gehängt) oder kurz nach dem Fahren: nicht automatisch einsteigen.
|
||||
if (Time.time - lastDriving < AfterDrivingPause) { dwellStart = -1f; return null; }
|
||||
CharacterController cc = player.GetComponent<CharacterController>();
|
||||
if ((cc != null && !cc.enabled) || player.parent != null) { lastDriving = Time.time; dwellStart = -1f; return null; }
|
||||
if (Time.time < nextAutoCheck) return null;
|
||||
nextAutoCheck = Time.time + AutoCheckInterval;
|
||||
Vector3 head = cam.transform.position;
|
||||
@@ -107,6 +115,10 @@ namespace MSCO
|
||||
if ((b.Rb.transform.TransformPoint(seat.Value) - head).sqrMagnitude > AutoEnterRange * AutoEnterRange) continue;
|
||||
Vector3 local = b.Rb.transform.InverseTransformPoint(head);
|
||||
if (Mathf.Abs(local.x) > Mathf.Abs(seat.Value.x) + AutoEnterSide) continue;
|
||||
// Nur von der Beifahrerseite her: Kopf auf der Seite des Beifahrersitzes und nicht weiter innen als der Sitz
|
||||
// (wer auf der Fahrerseite einsteigt, ist auf der anderen Seite bzw. in der Mitte)
|
||||
if (Mathf.Abs(seat.Value.x) >= CenterSeatThreshold
|
||||
&& (Mathf.Sign(local.x) != Mathf.Sign(seat.Value.x) || Mathf.Abs(local.x) < Mathf.Abs(seat.Value.x) - 0.1f)) continue;
|
||||
found = b;
|
||||
foundSeat = seat.Value;
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user