# How do you get "fort\_character" from type "?agent"

**URL:** <https://forums.unrealengine.com/t/how-do-you-get-fort-character-from-type-agent/882713>\
**Category:** Programming & Scripting\
**Tags:** unreal-editor-for-fortnite, fortnite-creative, question, fortnite\
**Created:** [April 10, 2023, 7:30am UTC](https://forums.unrealengine.com/t/how-do-you-get-fort-character-from-type-agent/882713 "2023-04-10T07:30:56Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![SushiAi](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/sushiai/32/88714_2.png) [@SushiAi](https://forums.unrealengine.com/u/SushiAi)\
**Post date:** [April 10, 2023, 7:30am UTC](https://forums.unrealengine.com/t/how-do-you-get-fort-character-from-type-agent/882713/1 "2023-04-10T07:30:56Z")

</div>

I’m subscribing to a “trigger\_device” TriggeredEvent and it asks for type “?agent” in params. How do I get a “fort\_character” from this?

VSCode is giving me a squiggly under the “GetFortCharacter” square brackets saying this:  
“This function parameter expects a value of type tuple(agent,tuple(),tuple()), but this argument is an incompatible value of type tuple(?agent,tuple(),tuple()).(3509)”

````auto
    @editable
    Trigger: trigger_device = trigger_device{}

    # Runs when the device is started in a running game
    OnBegin<override>()<suspends>:void=
        Trigger.TriggeredEvent.Subscribe(OnTriggered)

    OnTriggered(Agent: ?agent): void=
        if (Agent <> false, FortChar: fort_character = Agent.GetFortCharacter[]):
            block:```
````

---

<div class="post-metadata">

**Author:** ![SushiAi](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/sushiai/32/88714_2.png) [@SushiAi](https://forums.unrealengine.com/u/SushiAi)\
**Post date:** [April 10, 2023, 7:36am UTC](https://forums.unrealengine.com/t/how-do-you-get-fort-character-from-type-agent/882713/2 "2023-04-10T07:36:05Z")

</div>

Solved this by doing the following…

- Created a new const “Agent” of type “agent”
- Set “Agent” equal to “QAgent?”
- Called “GetFortCharacter[]” on the new const “Agent”

Looks like the question mark at the end handles the “false” check

```auto
OnTriggered(QAgent: ?agent): void=
  if (QAgent <> false, Agent: agent = QAgent?):
  
      if (FortChar := Agent.GetFortCharacter[]) {
          Print("Killing player")
          FortChar.Damage(100.0)
      }
```

---

<div class="post-metadata">

**Author:** ![Incredulous\_Hulk](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/incredulous_hulk/32/924210_2.png) [@Incredulous\_Hulk](https://forums.unrealengine.com/u/Incredulous_Hulk)\
**Post date:** [April 10, 2023, 6:12pm UTC](https://forums.unrealengine.com/t/how-do-you-get-fort-character-from-type-agent/882713/3 "2023-04-10T18:12:43Z")

</div>

Hey @SushiAi,

You don’t actually need the `QAgent <> false` check in here. The second part of your code already performs that part of the check with the `?` operator.

There are also a couple tricks that you can use to shrink the code more if you wanted. Posting them here to spread some knowledge.

```auto
# You can roll up the two ifs into one to save some indentation
if (Agent := QAgent?; FortChar := Agent.GetFortCharacter[])

# You can also use the ? with the GetFortCharacter call. This will only pass if QAgent has an agent and GetFortCharacter succeeds.
if (FortChar := QAgent?.GetFortCharacter[]):

```

---

<div class="post-metadata">

**Author:** ![Sarmess](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Sarmess](https://forums.unrealengine.com/u/Sarmess)\
**Post date:** [March 7, 2024, 3:30pm UTC](https://forums.unrealengine.com/t/how-do-you-get-fort-character-from-type-agent/882713/4 "2024-03-07T15:30:14Z")

</div>

@SushiAi how do you get an agent type from a fort\_character? i tried this but it wont work.

```auto
OnPlayerDamageChair(DamageResult : damage_result)<suspends>: void =
        Print("OnPlayerDamageChair activated")

        if:
            Instigator := DamageResult.Instigator?
            Agent := Instigator.GetInstigatorAgent[]  
            ChairGun.IsHoldingItem[Agent]
            Target := fort_character[DamageResult.Target]

        then:
            Print("then activated")

            if(TargetAgent:agent = agent[Target]):
                MyChair.Seat(Agent)
                OtherChair.Seat(TargetAgent)

```

---

<div class="post-metadata">

**Author:** ![nachoboy999](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@nachoboy999](https://forums.unrealengine.com/u/nachoboy999)\
**Post date:** [June 30, 2024, 7:06pm UTC](https://forums.unrealengine.com/t/how-do-you-get-fort-character-from-type-agent/882713/5 "2024-06-30T19:06:19Z")

</div>

`.GetAgent[]` on the fort\_character
