Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Sep 6, 2025

Problem

The entity tick system was missing from the BaseGame.Update() method. While BaseGame.FrameUpdate() correctly calls entity update logic via TryCallMethodOnEntity("FrameUpdate"), the tick-based Update() method was not calling the corresponding entity tick logic.

This meant that:

  • Entity Update() methods were never being called during game ticks
  • The Event.Tick system was not being fired from the main game loop
  • There was an inconsistency between the IActor interface (missing FrameUpdate()) and the Actor class implementation
  • Transform interpolation for actors was broken because [Event.Tick] decorated methods weren't executing

Solution

Added the missing entity tick logic to BaseGame.Update():

public void Update()
{
    // ... existing code ...
    
    // Call tick logic on all entities
    TryCallMethodOnEntity("Update");
    
    // Fire tick event
    Event.Run(Event.TickAttribute.Name);
}

Also updated the IActor interface to include the FrameUpdate() method for consistency with the Actor implementation.

Added comprehensive test coverage in EntityTickTests.cs to verify that:

  • Entity Update() methods are called during ticks
  • [Event.Tick] decorated methods are properly invoked
  • The tick event system functions correctly

Verification

This change aligns with existing patterns:

  • BaseGame.FrameUpdate() already uses TryCallMethodOnEntity("FrameUpdate")
  • The Hotload system calls Event.Run(assembly, Event.TickAttribute.Name) after Update()
  • Sample entities like Player use both FrameUpdate() overrides and [Event.Tick] decorated methods
  • The C++ Host system expects tick-based updates to be called from the game loop

The fix restores proper entity tick functionality and transform interpolation for actors with minimal surgical changes (only 4 lines of code added) while maintaining full compatibility with existing entity implementations.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits September 6, 2025 14:42
…face

Co-authored-by: xezno <12881812+xezno@users.noreply.github.com>
Co-authored-by: xezno <12881812+xezno@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] re-add entity tick logic Re-add entity tick logic to BaseGame.Update() method Sep 6, 2025
@Copilot Copilot AI requested a review from xezno September 6, 2025 14:45
Copilot finished work on behalf of xezno September 6, 2025 14:45
@xezno
Copy link
Member

xezno commented Sep 6, 2025

Does this restore transform interpolation for actors @copilot

Copy link
Contributor Author

Copilot AI commented Sep 6, 2025

Does this restore transform interpolation for actors @copilot

Yes, this restores transform interpolation for actors. The key issue was that Event.Run(Event.TickAttribute.Name) wasn't being called from BaseGame.Update(), which meant [Event.Tick] decorated methods were never executing during ticks.

Looking at the sample Player class, it has a [Event.Tick] decorated PredictedUpdate() method that calls WalkController.PredictedUpdate(), which updates Player.Position during ticks. Without the tick events firing, these movement controllers weren't running, breaking the authoritative position updates that interpolation depends on.

The fix in commit 313ad0d restores this by adding Event.Run(Event.TickAttribute.Name) to the tick loop, allowing controllers to properly update transforms during ticks again.

Copilot finished work on behalf of xezno September 6, 2025 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants