Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion 3D/Behaviors/TickedVehicle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,27 @@ public abstract class TickedVehicle : Vehicle

[SerializeField] private bool _traceAdjustments = false;

/// <summary>
/// For use with non-kinematic RigidBody components.
/// </summary>
/// <remarks>
/// Steering behaviours can conflict with movement of game objects containing a
/// RigiBody which is not set as 'kinematic'. Enable this if you want RigidBody
/// forces (inertia, collision, etc) combined with steering forces.
/// See https://github.com/ricardojmendez/UnitySteer/issues/54
/// </remarks>
[SerializeField] private bool _combineRigidBodyForces = false;

/// <summary>
/// A multiplier for steering forces applied when using 'Combine Rigid Body Forces'.
/// </summary>
/// <remarks>
/// For ease of configuration, rather than adjusting the forces of various steering
/// behaviours when switching over to blending RigdBody forces with steering forces,
/// use this multiplier to balance the steering forces which are added to RigidBody.
/// </remarks>
[SerializeField] private float _rigidBodyPrescalar = 10f;

#endregion

public CharacterController CharacterController { get; private set; }
Expand Down Expand Up @@ -254,7 +275,14 @@ private void ApplySteeringForce(float elapsedTime)
}
else
{
Rigidbody.MovePosition(Rigidbody.position + acceleration);
if (_combineRigidBodyForces)
{
Rigidbody.AddForce(acceleration * _rigidBodyPrescalar);
}
else
{
Rigidbody.MovePosition(Rigidbody.position + acceleration);
}
}
}

Expand Down