1
This commit is contained in:
@@ -22,6 +22,8 @@ namespace BITKit.Vehicles
|
||||
[SerializeField] private new Rigidbody rigidbody;
|
||||
[SerializeField] private new Collider collider;
|
||||
[SerializeField] private Transform model;
|
||||
|
||||
[SerializeReference,SubclassSelector] private IPlayerFixedPlace fixedPlace;
|
||||
|
||||
private Vector2 _movement;
|
||||
|
||||
@@ -32,9 +34,10 @@ namespace BITKit.Vehicles
|
||||
private bool _hover;
|
||||
private bool _reset;
|
||||
|
||||
private IPlayerFixedPlace _fixedPlace;
|
||||
|
||||
private Transform Transform;
|
||||
private Vector3 _initialPosition;
|
||||
private Vector3 _initialPosition;
|
||||
private readonly ValidHandle _resetHandle=new();
|
||||
|
||||
private void Start()
|
||||
{
|
||||
@@ -50,6 +53,9 @@ private Vector3 _initialPosition;
|
||||
var newRotation = Quaternion.LookRotation(Vector3.ProjectOnPlane(Transform.forward, Vector3.up));
|
||||
|
||||
rigidbody.MoveRotation(newRotation);
|
||||
|
||||
fixedPlace.OnPlayerEntered += x => _resetHandle.RemoveElement(111);
|
||||
fixedPlace.OnPlayerExited += x => _resetHandle.AddElement(111);
|
||||
}
|
||||
|
||||
private void FixedUpdate()
|
||||
@@ -59,7 +65,7 @@ private Vector3 _initialPosition;
|
||||
var offsetX = Mathf.PerlinNoise(Time.time, 0) - 0.5f;
|
||||
var offsetY = Mathf.PerlinNoise(0, Time.time) - 0.5f;
|
||||
|
||||
|
||||
_resetHandle.SetElements(123,_reset);
|
||||
|
||||
rigidbody.useGravity = !_hover;
|
||||
|
||||
@@ -70,7 +76,8 @@ private Vector3 _initialPosition;
|
||||
var moveForce = up * (_AscendAndDescend * upForce * Time.fixedDeltaTime);
|
||||
|
||||
var newRotation = Quaternion.LookRotation(Vector3.ProjectOnPlane(Transform.forward, Vector3.up));
|
||||
if (_reset)
|
||||
|
||||
if (_resetHandle)
|
||||
{
|
||||
rigidbody.AddTorque(MathV.CalculateTorque(Transform,newRotation) * (torqueResetDelta * Time.fixedDeltaTime),
|
||||
ForceMode.VelocityChange);
|
||||
@@ -161,7 +168,5 @@ private Vector3 _initialPosition;
|
||||
_reset = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user