How to use JumpedEvent?

It says “This function parameter expects a value of type fort_character->void, but this argument is an incompatible value of type tuple(fort_character,logic)->void.”
If anyone could help much would be appreciated. I want the movement__modulator_device to activate when you jump

Jump_device := class(creative_device):

@editable
ModDevice : movement_modulator_device = movement_modulator_device{}
@editable
spawner : player_spawner_device = player_spawner_device{}

ActivateOnJump( FortCharacter : fort_character, JumpedEvent : logic) : void =
    if (JumpedEvent?):
        ModDevice.Activate

HandleSpawnEvent (Agent : agent) : void =
    if (FortCharacter := Agent.GetFortCharacter[]):
        FortCharacter.JumpedEvent().Subscribe(ActivateOnJump)
OnBegin<override>()<suspends>:void=
    spawner.SpawnedEvent.Subscribe(HandleSpawnEvent)

Hi, here’s an updated version of your code. Untested, but no type errors. I’ve not used the movement modulator device and I’m not sure how Disable and Activate are going to work without trying it.

    @editable
    ModDevice : movement_modulator_device = movement_modulator_device{}

    @editable
    Spawner : player_spawner_device = player_spawner_device{}

    var MaybeTargetAgent: ?agent = false

    var JumpStarted: logic = false

    ActivateOnJump(FortCharacter : fort_character) : void = 
        # This event indicates a jump has happened
        if(CharacterAgent := FortCharacter.GetAgent[]):

            ModDevice.Activate(CharacterAgent)

        set JumpStarted = true

    HandleSpawnEvent (Agent : agent) : void =
        if (FortCharacter := Agent.GetFortCharacter[]):

            FortCharacter.JumpedEvent().Subscribe(ActivateOnJump)

            set MaybeTargetAgent = option{Agent}

    OnBegin<override>()<suspends>:void=
        Spawner.SpawnedEvent.Subscribe(HandleSpawnEvent)

        loop:

            if(TargetAgent := MaybeTargetAgent, FortCharacter := TargetAgent.GetFortCharacter[]):

                if(JumpStarted = true and FortCharacter.IsOnGround[]):

                    set JumpStarted = false

                    ModDevice.Disable()

            Sleep(0.0)
1 Like

Thank you sm!! youre a goat. Im gonna try it now

Your welcome! once you’ve tested it out and if it does what you’d hoped - It will need to be updated to track that jumping variable per player agent reference for multiplayer which isn’t too difficult to set up.