Extending
Every hook below exists because the framework would otherwise have to guess at something only your game knows. None of them is required.
A rule about who may sit where
Two layers, and you can use either or both.
Tags, for the common case. Put a query in the seat's RequiredRiderTags and answer
IEDRiderInterface::GetRiderTags from wherever your game already keeps them — an ability system
component, an inventory, a faction field:
void AMyCharacter::GetRiderTags_Implementation(FGameplayTagContainer& OutTags) const
{
if (const UAbilitySystemComponent* ASC = GetAbilitySystemComponent())
{
ASC->GetOwnedGameplayTags(OutTags);
}
}
The framework does not care where they come from, deliberately: requiring an ability system would make the plugin depend on one.
Code, for everything else. Implement IEDMountableInterface::CanAcceptRider on the mount:
bool AMyVehicle::CanAcceptRider_Implementation(APawn* Rider, FEDSeatHandle Seat,
const FGameplayTagContainer& ContextTags) const
{
return !bEngineOnFire && GetTeamOf(Rider) == OwningTeam;
}
It runs after the framework's own checks and on the server as well as the predicting client, so a rule written here is authoritative rather than cosmetic. Keep it cheap and keep it pure: it is called once per seat when a rider asks for "any seat", and again during the query that drives your interaction prompt.
Temporary access — an ability that lets you hotwire a locked car — goes through
FEDMountRequest::ContextTags, which are appended to the rider's tags for that one request without
changing anything about the pawn.
A new kind of mount
There is nothing to do. A mount is an actor with a UEDMountableComponent and at least one seat. The
example project's turret is an actor with a static mesh and no physics; a ski lift would be an actor
with a seat parented to a moving component.
If it is steerable, implement ApplyDriverInput and decide what the axes mean. The turret uses the X
axis for yaw and Y for pitch; a boat would use X for the rudder.
Three base classes, if you would rather not start from nothing
Each is the work above done once — a mountable component, the interface, replication turned on — and
each is Blueprintable, so a Blueprint deriving from it can override Apply Driver Input, On Rider Seated, On Rider Left, Set Seat Door Open and Can Accept Rider as events:
AEDMountableActor | Anything you get onto that stays put or is carried: a bench, a turret, a trailer, a lift. |
AEDMountableCharacter | A mount that walks. Character movement gives a ridden animal a walk, a jump, a step height and a slope limit for nothing. |
AEDMountableVehicle | Wheels. See Vehicles. |
You do not have to use any of them — a mountable component dropped on an actor of your own works exactly as well. What they save is one thing that cannot be worked around from a Blueprint alone: a Blueprint cannot add a C++ interface to itself except through the class settings dialog, so a mount authored entirely in Blueprint, or by a script, cannot hear its driver unless the interface is already on its parent. A mount that cannot hear its driver is a mount you can sit on and nothing more.
AEDMountableCharacter also turns on bRunPhysicsWithNoController, which is the setting everybody
meets the hard way: character movement discards its input when the pawn has no controller, and under
the KeepRider policy a ridden mount has none — the rider keeps theirs. Left off, the animal answers
every key with nothing and there is no warning anywhere.
All three carry ChildCanTick, because they do not tick themselves and a Blueprint deriving from one
usually wants to. Without the metadata the compiler quietly refuses a Tick event on a subclass of a
parent that turned ticking off: the graph is there, it compiles, and it never runs.
A new moment in a transition
Declare a tag under Mount.Event, put a UAnimNotify_EDMountEvent carrying it on the frame it should
happen, and listen:
Rider->OnMountEvent.AddDynamic(this, &AMyCharacter::OnMountEvent);
void AMyCharacter::OnMountEvent(FGameplayTag EventTag, APawn* WhichRider)
{
if (EventTag == MyTags::Mount_Event_GrabHandle) { PlayHandSound(); }
}
The framework forwards anything it does not recognise, to both the rider and the mount, and does
nothing else with it. Mount.Event.Attach, .Detach and .Finished are the three it acts on itself.
A different animation for a case the fields do not cover
FEDMountAnimEntry::ContextQuery is an arbitrary FGameplayTagQuery against the rider's tags, the
mount's tags and the request's tags together. A wounded character who climbs in slowly is a query
against your own injury tag, not a field added to the plugin.
That is the extension point that keeps the entry struct from growing one boolean per game.
Different behaviour for the rider's body while seated
FEDRiderPolicy, per seat. Everything in it is something the systems this replaces hard-coded and
something a game eventually needs to change: a turret gunner keeps their capsule, a horse rider keeps
their movement component so they can be knocked off, a passenger in a cutscene keeps everything.
Whatever is captured on the way in is restored exactly on the way out, from the capture rather than from assumed defaults.
Reacting to occupancy from somewhere else
Mountable->OnSeatOccupancyChanged.AddDynamic(this, &AMyHud::OnSeatChanged);
Mountable->OnMountableChanged.AddDynamic(this, &AMyHud::OnMountableChanged);
Rider->OnMountPhaseChanged.AddDynamic(this, &AMyHud::OnPhaseChanged);
Rider->OnMountFailed.AddDynamic(this, &AMyHud::OnFailed);
Occupancy and phase fire on every machine, including simulated proxies, so a HUD showing who is in which seat needs no replication of its own. Failures fire only where the request was made.
Placing a pawn in a seat from script
FEDMountRequest Request;
Request.MountActor = Vehicle;
Request.DesiredSeat = Vehicle->GetMountable()->FindSeatByName(TEXT("Driver"));
Request.bAllowSeatFallback = false; // that seat or nothing
Request.bInstant = true; // no animation, and no distance check
Rider->RequestMountWithOptions(Request);
bInstant bypasses reach as well: an actor being placed into a seat by script is not walking there.
This is the path for spawning already-seated, for save-game restore, and for cutscene setup.
Driving the transition from your own code
UEDRiderComponent::HandleMountEvent is public. Everything the framework does at a specific frame goes
through it, so a game that drives its transitions from something other than anim notifies — a timeline,
a sequencer track, a state tree — can call it directly with Mount.Event.Attach and
Mount.Event.Finished at the right moments.
Where to be careful
CanAcceptRiderruns often. Once per seat per query, and the query may run every frame for a prompt. Do not trace in it.- Do not change a seat's transform every frame in code. Parent it to something that moves instead; that is what makes it free.
- Do not write to
FEDMountStateyourself. It is the server's, and the sequence number is what keeps prediction honest.