mirror of
https://github.com/hanetzer/sdraw_mods_cvr.git
synced 2025-09-05 03:19:23 +00:00
Improved rotations
This commit is contained in:
parent
dce5acf2c6
commit
b4a210a546
2 changed files with 32 additions and 6 deletions
|
@ -1,4 +1,8 @@
|
|||
using UnityEngine;
|
||||
using ABI_RC.Core;
|
||||
using ABI_RC.Core.Player;
|
||||
using ABI_RC.Systems.Movement;
|
||||
using ABI_RC.Systems.Safety.AdvancedSafety;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ml_ppu
|
||||
{
|
||||
|
@ -8,5 +12,20 @@ namespace ml_ppu
|
|||
{
|
||||
return Matrix4x4.TRS(p_pos ? p_transform.position : Vector3.zero, p_rot ? p_transform.rotation : Quaternion.identity, p_scl ? p_transform.lossyScale : Vector3.one);
|
||||
}
|
||||
|
||||
// Remade method to remove Q-E-Q conversions to prevent bad angles
|
||||
public static void TeleportPlayerTo(this BetterBetterCharacterController p_instance, Vector3 p_targetPos, Quaternion p_targetRot, bool p_interpolate, bool p_updateGround, bool p_preserveVelocity = false)
|
||||
{
|
||||
Quaternion l_quaternion = p_targetRot * Quaternion.Inverse(PlayerSetup.Instance.GetPlayerRotation());
|
||||
Quaternion l_newRotation = l_quaternion * p_instance.characterMovement.rotation;
|
||||
if(l_newRotation.eulerAngles.IsAbsurd())
|
||||
{
|
||||
CommonTools.LogAuto(CommonTools.LogLevelType_t.Warning, "Attempted to teleport using an absurd rotation. Ignoring it...", "", "Assets\\ABI RC\\Systems\\Movement\\BetterBetterCharacterController.cs", "TeleportPlayerTo", 1845);
|
||||
return;
|
||||
}
|
||||
p_interpolate = false;
|
||||
p_instance.TeleportRotation(l_newRotation, p_interpolate);
|
||||
p_instance.TeleportPlayerTo(p_targetPos, p_interpolate, p_updateGround, p_preserveVelocity, l_quaternion);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue