Camera now properly moving with player again.
parent
70724899ad
commit
48f7081134
|
@ -25,6 +25,7 @@ public class Game : Spatial
|
|||
private Player _player;
|
||||
private Chest _chest;
|
||||
private TileWorld _tileWorld;
|
||||
private Camera _camera;
|
||||
|
||||
// Resources
|
||||
private PackedScene _tileHighlightScene;
|
||||
|
@ -34,6 +35,7 @@ public class Game : Spatial
|
|||
private HexCell _lastTile;
|
||||
private HexCell _currentTile;
|
||||
private Vector2 _currentTileOffset;
|
||||
private Vector3 _cameraOffset;
|
||||
|
||||
// Called when the node enters the scene tree for the first time.
|
||||
public override void _Ready()
|
||||
|
@ -58,7 +60,9 @@ public class Game : Spatial
|
|||
_player = GetNode<Player>("Player");
|
||||
_chest = GetNode<Chest>("Entities/Chest");
|
||||
_tileWorld = GetNode<TileWorld>("TileWorld");
|
||||
|
||||
_camera = GetNode<Camera>("Camera");
|
||||
_cameraOffset = _camera.GlobalTranslation - _player.GlobalTranslation;
|
||||
|
||||
Debug.Assert(_tileWorld != null);
|
||||
|
||||
// resources
|
||||
|
@ -135,6 +139,7 @@ public class Game : Spatial
|
|||
}
|
||||
|
||||
|
||||
|
||||
public override void _Process(float delta)
|
||||
{
|
||||
_framesPerSecondLabel.Text = Engine.GetFramesPerSecond().ToString();
|
||||
|
@ -156,8 +161,11 @@ public class Game : Spatial
|
|||
_numCoordsAddedLabel.Text = _streamContainer.AddedCoords.Count.ToString();
|
||||
_numCoordsRemovedLabel.Text = _streamContainer.RemovedCoords.Count.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
Transform cameraTransform = _camera.Transform;
|
||||
cameraTransform.origin = _player.GlobalTranslation + _cameraOffset;
|
||||
_camera.Transform = cameraTransform;
|
||||
}
|
||||
|
||||
public void OnAreaInputEvent(Node camera, InputEvent inputEvent, Vector3 position, Vector3 normal,
|
||||
int shapeIndex)
|
||||
|
|
Loading…
Reference in New Issue