null check on body

This commit is contained in:
JohnCorby 2023-04-22 15:39:08 -07:00
parent 492aed3259
commit d30ed12ea8

View File

@ -39,8 +39,9 @@ namespace NewHorizons.Components.SizeControllers
private void UpdateTargetPositions()
{
var toPrimary = (_body.transform.position - _dustTargetBody.transform.position).normalized;
var velocityDirection = (_primaryBody?.GetVelocity() ?? Vector3.zero) -_body.GetVelocity(); // Accept that this is flipped ok
// body is null for proxies
var toPrimary = ((_body ? _body.transform : transform).position - _dustTargetBody.transform.position).normalized;
var velocityDirection = (_primaryBody?.GetVelocity() ?? Vector3.zero) - (_body ? _body.GetVelocity() : Vector3.zero); // Accept that this is flipped ok
var tangentVel = Vector3.ProjectOnPlane(velocityDirection, toPrimary) / velocityDirection.magnitude;