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
12 changes: 9 additions & 3 deletions Nez.Portable/ECS/Components/FollowCamera.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,15 +160,15 @@ void UpdateFollow()
}
else
{
// make sure we have a targetCollider for CameraWindow. If we dont bail out.
if (_targetCollider == null)
// make sure we have a targetCollider for CameraWindow attached to this Entity. If we dont bail out.
if (_targetCollider == null || _targetCollider.Entity != _targetEntity)
{
_targetCollider = _targetEntity.GetComponent<Collider>();
if (_targetCollider == null)
return;
}

var targetBounds = _targetEntity.GetComponent<Collider>().Bounds;
var targetBounds = _targetCollider.Bounds;
if (!_worldSpaceDeadzone.Contains(targetBounds))
{
// x-axis
Expand All @@ -188,6 +188,12 @@ void UpdateFollow()

public void Follow(Entity targetEntity, CameraStyle cameraStyle = CameraStyle.CameraWindow)
{
if (targetEntity != _targetEntity)
{
// new entity -> invalidate cached collider
_targetCollider = null;
}

_targetEntity = targetEntity;
_cameraStyle = cameraStyle;
var cameraBounds = Camera.Bounds;
Expand Down