Skip to content

RewindableAction.set_active() will not execute in tick when rbs cannot simulate. #517

@RickyYCheng

Description

@RickyYCheng

🐛 Description

A RewindableAction will confirm multiple times even only emit set_active(true) once when enable_prediction is not toggled.


Further more, the value of _active_ticks in r-act is different between two states.

Steps to reproduce

By creating a rollback npc without enable prediction, we can see has_confirmed() will produce different behaviours with different enable_prediction states.

extends CharacterBody2D

@onready var rewindable_action = $RewindableAction

func _after_loop() -> void:
    if rewindable_action.has_confirmed():
        if not multiplayer.is_server():
            print("confirmed")

func _enter_tree():
    if Engine.is_editor_hint(): return
    
    NetworkTime.after_tick_loop.connect(_after_loop)

func _exit_tree():
    if Engine.is_editor_hint(): return
    
    NetworkTime.after_tick_loop.disconnect(_after_loop)

func _rollback_tick(dt, _tick, _is_fresh: bool):
    rewindable_action.set_active(_tick == 30 * 10)

Toggle enable_prediction to see diferent behaviours.

Additionally, see mre.

Expected behavior

Log only once for both situtations.

Observed behavior

Output:

confirmed * 1, enable_prediction = true
confirmed * 52, enable_prediction = false

Versions

  • Godot version: Godot v4.4.1.stable.mono, Godot v4.1.3
  • netfox version: 1.33.1

Notes

MRE

ract.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions