LogoLogo
API Status
  • 👋Welcome
  • 🌐What is Morpheus Platform?
    • Interoperability
  • ℹ️Help
    • 📗Glossary
    • 🆘Support
    • Firewall problems
    • EULA
  • CREATION
    • 🎮Unreal Development
      • ⚡Get Started
        • ⚒️Download the Editor
        • ⏫Upload Content
        • 🌎Creating your own map
        • 📝Morpheus Base Project
        • ❓Differences from Unreal
          • 🧍Character Configuration
        • 📡Morpheus Networking
          • Introduction to Morpheus Networking
          • Network Levels
          • Replicated Properties
          • RPCs
          • Morpheus Render Targets
          • Morpheus Array
          • Networking FAQ
          • Replicating Sublevels
      • 📚Features & Guides
        • 📒Example Plugin
          • Nameplates
          • In-game roles
          • Resizing
        • 🏊Actor Pooling
        • 🔊Audio
        • 🎭Avatars
          • Creating an Avatar
          • Attachments
            • MML Attachments
          • Custom Animation Variables
          • Importing an NFT collection
          • Capsules and Mesh Transforms
        • 🤖Bots
        • 🎙️Chat
          • Unreal Text Chat
        • 🎛️Control Panels
          • Control Panel Configuration
          • DJ booth mission control
          • Observer Controls
        • 🔉Crowd Audio
        • 🤼Crowd Rendering
          • Legacy Animated Crowd
            • Animated Crowd Console Commands
            • Attaching static meshes to crowd members
          • Crowd Materials
          • Performance Parameters
          • Live Config Settings
          • Crowd Animation
            • Crowd Anim Blueprint
              • User Guide - Crowd Anim Blueprint
              • Reference Guide - ABP Nodes
                • Animation Playback
                • States and State Machines
                • Variables
                • Transitions
                • Special
                • Blends
                • Additional Notes
        • 🍱Helpers & Extras
          • "Instanced Objects" in Blueprints
          • Objects with "world context"
          • Making DataAsset classes
          • Duplicate Objects
          • The Bootflow Subsystem
          • The "Wait For Condition" System
          • Advanced Graphics settings
          • Listening to inputs on UObjects
          • Morpheus UserID
          • World Services
          • M2Extras: Skins System
        • 🖥️Loading Screen
        • ⚡Live Config
          • Editing for a World
          • Editing Locally
          • Default Settings
          • Accessing via Blueprint
          • Adding New Settings
          • Overriding Defaults
          • Using Arrays
        • 🧊MML
        • 🕺Motion Capture
        • 📡Networking
        • 📢Notifications
        • Raycastable Crowd
        • 🌐Singletons
        • 📱Streaming & Multiplatform
          • GFN on mobile
        • 🖥️UI
          • "UI Mode"
        • 🗃️User Collections
          • Creating a New Object Definition
          • Accessing from Unreal
            • Creating Objects Definitions
            • Transfer Objects
            • User Collection Views
            • Receiving Updates
        • 📺Video Players
          • Embedded Video Player
          • Millicast video streaming
            • How to Setup an In-Game Video Stream
            • Picture-in-Picture mode
          • Streaming Video Player
            • How to Setup a URL Video Player
            • Picture-in-Picture mode
        • 🐞Visual Debugging
          • Inspector
        • 🪟Web UI
        • Online Services
          • KV Store Service
        • 💠Web Requests
          • Http Requests
            • Legacy HTTP Nodes
          • JSON Handling
          • WebSockets
          • Identity Validation
          • Allowed External URLs
          • Walkthrough Example
            • Example Counter Service
        • ✈️World Travel
          • World Travel in the editor
        • Avatar Physics Assets
        • Action Gameplay Helper Components
      • 🔑Workflows
        • ↗️Upgrade the Editor
          • 🖥️Version History
        • ⚙️Editing Project Settings
        • 📈Profiling
        • 🧺Marketplace Importing
        • 🛠️Extra Workflows
          • Setup Play-in-Editor
          • Setup Local Asset Validation
          • Adding Gameplay Tags
          • Validating Game Assets
          • Custom Connection Modes
          • Connect Editor to a World
          • Common Issues
      • 📚Useful Reading
        • ⭐Best Practices
    • 🌎Worlds
      • 📩Invite Players
        • Setting Role Groups
      • Persistent Worlds
      • Always on Worlds
    • 📅Running events
      • ✅Large scale events - Checklist
      • 👾Anti-Cheat (EAC)
      • 🎮Player Entry
        • 📱React Native
        • Steam
        • 💻Hardware Reqs
      • 🎥Broadcast
        • 📹OBS Integration
      • Failover
      • 🏁Capacity And Queue Management
  • ADMINS
    • 👪Access Control
      • Adding metaverse contributors
      • Creating a new project
    • 💲Pricing
      • Development Support
      • Included Usage & Overages
      • Cloud Streaming
      • Access Modes
      • War Room Support
      • Platform SLA
    • ⚙️Settings
      • 🗃️Projects
  • APIs and Tooling
    • 🖥️API Reference
      • Accounts
      • Events
      • Key/Value Store
      • Organizations
      • Realtime
      • User Profile
      • World Builder
      • Worlds
    • 💻Template Web App
      • 💢Moderation
    • Pixel Streaming
    • 🚀Launcher
  • Integrations
    • 📊Analytics
      • Sending events from web
      • 🎮Sending Events from Unreal
    • 💬Chat
      • 🎮Integrating Pubnub with your Unreal Project
      • Adding Moderation to Chat
Powered by GitBook
On this page
  • Overview
  • Combat Flow
  • Combat Component
  • Usage overview
  • API reference
  • Shootable Component
  • Usage overview
  • API reference

Was this helpful?

  1. CREATION
  2. Unreal Development
  3. Features & Guides

Action Gameplay Helper Components

Morpheus provided components to help you network shooter-related gameplay.

PreviousAvatar Physics AssetsNextWorkflows

Last updated 3 months ago

Was this helpful?

Overview

The Morpheus Platform contains components that you can add to your Morpheus Character to help you network common parts of a shooter game, such shooting a target, having the target respond, and observers being able to see the interactions. The main pieces are these two components:

  • Shootable Component: Used to configure and replicate behaviour related to the target of a shot, such as playing on-hit effects to everyone and taking damage.

  • Combat Component: Used to configure and replicate behaviour related to the actor that fired the shot, such as sending an RPC to the target and playing the shot-fired effects for everyone.

These components are not necessary to create a shooter game with the Morpheus Platform, and you can create your own networked state and RPCs instead!

However, replicating state related to shooter gameplay using midground and background properties efficiently can be tricky, so we would recommend using these components if you're new to the platform. Additionally, these components are what we use to verify that shooter-style gameplay works at scale.

Combat Flow

First, let's look at the flow of events that happens when a player shoots a target (such as another player or replicated object). The player has a Combat Component, and the target has a Shootable Component. In practice, players usually have both a Combat and Shootable component. Shooter and Target refer to MorpheusActors that are shooting and being shot at respectively.

  1. (Shooter's client): Shooter fires their weapon and determines the target(s), e.g. via a line trace.

  2. (Shooter's client): Call Shooter.CombatComponent.Fire(). This replicates to observers that a shot has been fired with some data about the shot.

  3. (Shooter's client): Call Shooter.CombatComponent.ApplyShotToTarget(). This does some validation logic, and if successful, sends an RPC to the target client (which must have a ShootableComponent) indicating the target should take damage.

  4. (Shooter's client): Call Target.ShootableComponent.LocalValidateShot(). This is the stage for the shooter to locally predict whether the shot is a valid shot; for example, is the target alive and not immune to damage?

  5. (Shooter's client): If the above validation passed, send RPC to target's client.

  6. (Target's client): Call Target.ShootableComponent.AuthIsShotValid. This is the stage for the target's client to authoritatively determine whether the shot was valid, in case of mispredictions.

  7. (Target's client): Call Target.ShootableComponent.ValidShotReceived. This authoritatively processes the effects of the shot; for example, taking damage.

  8. (Target's client): Send an RPC to the shooter's client indicating the shot was successful and what effects the shot had.

  9. (Shooter's client): Call Shooter.CombatComponent.OnShotAcknowledged. This is the stage to play hit markers and update kill counters.

Additionally, the above flow causes delegates to replicate in the midground and background whenever a shot is fired (from the Combat Component) and whenever a shot is received (from the Shootable Component).

Combat Component

Usage overview

The Combat Component handles the Shooter's part of the replication: firing a shot, and receiving an acknowledgment that the shot is fired. To use the Combat Component, you can directly add an M2M_CombatComponent to your Morpheus Character class, or you can create a child component.

Typical usage is for the Shooter to call Fire when the shot is fired, and to bind to OnShotFired to play any visual or sound effects of the shot. Fire allows you to pass custom data about the shot, such as a weapon index or other custom data, which is passed to OnShotFired . OnShotFired is replicated in the midground, so all nearby players can play the full accurate effects of the shot.

If a player sees the Shooter in the background net relevancy level, OnShotFiredBackground is called instead. Since the background includes all players not in the fore/midground, this should be used to play any lightweight effects of the shot.

The Shooter then calls ApplyShotToTarget , which sends a request to the target's ShootableComponent . On the Shooter's client, the target validates whether the shot is valid, and if this passes then this is send as an RPC to the target's client. The ShootableComponent processes the shot and sends an RPC back to the Shooter's client, which broadcasts OnShotAcknowledged . Bind to OnShotAcknowledged for things like hit markers.

API reference

Functions

  • Fire: Call when your Shooter fires a shot. Causes the OnShotFired events to replicate to observers with the data supplied.

  • FireShotNumOverride : For an advanced use case. Each shot when fired replicates a ShotNum to observers; a unique integer that increments with every shot. FireShotNumOverride allows you to override the ShotNum field that is replicated, allowing your shot to reference a previous shot, for example if your shot effects occur in multiple stages.

  • FireHitResult : A utility function that calls Fire but populates the parameters from a given FHitResult .

  • ApplyShotToTarget : Call when your Shooter's shot damages a target. Can be called on multiple targets, and doesn't need to be called simultaneously with Fire in the case where your shot effects are separated from the shot firing (e.g. non hitscan weapons).

  • ApplyShotToTargetHitResult : Similar to FireHitResult , a helper function for ApplyShotToTarget .

Events

  • OnShotFired : Broadcast on all clients who are in the Shooter's Foreground and Midground net relevancy levels whenever the Shooter shoots with Fire(). Bind to this to play the effects of a shot being fired such as the VFX of a muzzle flash or beam. Contains data that was passed to the Fire() function such as destination and custom data.

  • OnShotFiredBackground : Broadcast on all non-auth clients in the Shooter's Background whenever the Shooter shoots. For performance reasons, this contains no data, but you can use GetBackgroundWeaponIndex to determine the WeaponIndex and GetBackgroundShotEndPoint to get an approximate end destination of the shot. Bind to this to play your low fidelity, approximate effects for shots that are happening in the distance.

  • OnTargetHit : Broadcast on auth client only when you shoot a target locally, before any RPCs. Bind to this to play any local prediction effects.

  • OnShotAcknowledged : Broadcast on auth client when the shot has been received by the receiver's client and the effects of the shot have been sent back to the Shooter. This contains data about the effects of the shot, such as whether it killed the player. Bind to this to play shot confirmation effects, such as hit markers.

Shootable Component

Usage overview

The Shootable Component handles the Target's part of replication: receiving an RPC with the data about a shot they have received; applying the effects of the shot on the Target; and replicating the effects of the shot to observers and the Shooter. To use the Shootable Component, you will probably need to subclass M2M_ShootableComponent and add it to your Morpheus Character.

Usage is to override some functions to determine whether the shot is valid and to apply the effects of the shot. These are:

  • LocalIsShotValid : Called on the Shooter's client to determine whether the Shooter's client thinks the shot is valid. Use for local prediction purposes, such as whether the Target is on the correct team, isn't already dead, or had some invulnerability ability active. If this passes, the shot data is sent as an RPC to the Target's client. The result of this validity check is also passed to Shooter.CombatComponent.OnTargetHit.

  • AuthIsShotValid : If the above validity check passes and the shot is send as an RPC, this function is run on the Target's client. Use to authoritatively determine whether the shot is valid.

  • ValidShotReceived : If the above validity check passes, this is called on the Target's client to process the effects of the shot. This function is the place where the player should change their state as a result of being shot, such as reducing their health. This also returns data that is sent as an RPC back to the Shooter's client to let them know what effects the shot had.

If the shot is valid, the Shootable Component broadcasts delegates. OnHitReceived is broadcast to the midground with data relating to the shot and the data populated by CombatComponent.Fire. Bind to this to play the effects of the Target being hit such as damage effects and animations.

OnHitReceivedBackground is broadcast to the background with no additional data, so should be used to play lightweight, low fidelity effects of the Target being hit.

API reference

Functions

  • LocalIsShotValid: Called on the Shooter's client to determine whether the Shooter's client thinks the shot is valid. Override with logic to determine if the Shooter thinks the shot is valid. If this passes, the shot proceeds to an RPC to the Target.

  • AuthIsShotValid: Called on target's client to authoritatively determine whether the shot is valid. Override with logic to determine if the Target thinks the shot is valid. If this passes, the shot proceeds to ValidShotReceived.

  • ValidShotReceived : Called on the target's client if AuthIsShotValid passes. Override to apply the effects of the shot (such as taking damage) and returning an acknowledgment with data about the effects to the shot to the Shooter's CombatComponent.

Delegates

  • LocalOnHitReceived : Broadcast on the Shooter's client when this actor is shot.

  • OnHitReceived : Broadcast for all observers who have the Shooter in foreground or midground, with full data relating to the shot. Bind to this to play damage taken effects on the Shooter.

  • AuthInvalidShotReceived : Broadcast on the Target's client if they received a shot that the Target determined was invalid.

  • OnHitReceivedBackground : Broadcast for all observers who have the Shooter in the background net relevancy level. Use to play lightweight, low fidelity effects of damage taken on the shooter.

🎮
📚