UEFN Capture the Flag tutorial - Flagcarrier and sprinting

I have played around with “Capture The Flag” tutorial and got a working game. What I would like to add to it is a way to disable sprinting for anyone picking up the flag. Is there any way to do this via code or some device? I have tried searching but cant find a direct way to do it, if anyone here as an idea of how to do this it would be great!

1 Like

You could use capture_item_spawner_device ItemPickedUpEvent to get the player who captured the flag.

But I do not see any way to disable sprinting. The best thing that comes to my mind is to use movement_modulator_device to reduce overall agent speed using Activate(Agent:agent) function.

Alternatively, but I see this as an ugly fix, you could subscribe to SprintedEvent from fort_character and use above function to reduce speed of character only when he is sprinting and return it to normal when player stops sprinting.

Thanks for the suggestions! I stopped at the same place you did. I got to the flag and saw you could subscribe to the events there to know if its picked up or dropped/delivered but could not see a way to access sprint. I noticed the SprintedEvent only too. I was thinking of an alternative to disable sprint and just have the character drop the flag if it tried to sprint. There is a device for dropping items so I think this might be possible, but I need to learn more to do it. Still trying to wrap my head around this verse coding :slight_smile:

I will take a look at the movement_modulator also, might want to set a fixed lower speed for flag carriers so that could be a good idea anyways, thanks for the tip!

You can disable sprinting with a class designer device.

I thought about that but, like have a flag carrier class, but is there a way to see what class the player has? And store this so when flag is dropped/delivered one can change back? Since like the example I set up 4 different classes and would need to return the player to its original class. I only found events that returned the agent.

I haven’t done this myself yet, but I would be surprised if the current class id is not exposed as a property on some class.

Thanks, I will have to look further into this. Would be a nice way of doing it. I guess one way could be to keep a list of all players and the class they choose since I do belive one can listen to the class selection devices and get the agents interacting with them. But would be nice if there is an ID exposed that one could get.

Ok, so I have tried with the class change approach and made it work, in a way. But it feels so cumbersome and awkward way of doing it. I did not find a direct way to get the player class id, so had to go what feels like the long way around. Will have to try and refactor it or see if there are better ways. Still having a hard time wrapping my head around how Verse works and what we can and cant do.

So what I basically did incase anyone has some good ideas:

  • Created a “FlagCarrier” Class with sprint disabled and some reduced speed, and a Flag Carrier Team selector device for this class.
  • Stored Teams and all players and their initial class in a Map container
  • For all the “class and team selector devices” I subscribed to when a player changes class. I had to separate these into the 4 classes, so they call their own function when activated since I did not find a way that would tell me what ID the selector had.
  • I then update the class value for the player in the Map I set up of teams and players
  • When you pick up the flag, the class gets changed to the “FlagCarrier” Class
  • When you drop or deliver the flag it sets it back to the class stored
2 Likes

So slight off topic, but figured I might get a quicker response here since you guys are working on this… I followed this Capture the Flag tutorial to a “T” and checked everything multiple times, and for the life of me I cannot pick up the flag when I play test my game. Obviously supposed to pick up the enemy team’s flag, but I tried both. My player walks up to the capture item spawner in game, and the HUD doesn’t give any interaction prompt (should be “E” on keyboard). What am I missing?? Thanks in advance!

Figured out my issue-- turns out you need an open slot in your inventory. When I created the Class “load outs” for my class selectors I filled all 5 slots with weapons/heals - even though the tutorial properly only instructs you to fill 4 of the slots. So my dumb mistake, but maybe it will help someone else. Sorry for hijacking this thread.

1 Like