Development

Hoverbike Multiplayer Development Log 2

Week 2: New Hoverbike movement behavior and replicating the mount icon visibility

Hello again! Ram here with another development log of the Hoverbike. 

Before fixing the movement of the hoverbike while replicating, first I decided to revamp the hoverbike blueprint. One of the few things that bothered me the most was that the hoverbike was using a character blueprint as base instead of a pawn blueprint. This limited the movement behavior that the hoverbike could achieve. Although this approach meant that the gravity would have to be simulated it gave better results than the previous one.

Now you can ride the walls! I need to tweak some values to achieve the movement I'm looking for but at the moment it is very pleasant to use the hoverbike.

This revamp took most of the time I dedicate to this project but I wanted to do some networking stuff before posting this article so I fixed the mount icon visibility. This icon shows up every time you are near the bike to notify you that you are able to ride bike. In single player this worked flawlessly but with multiplayer I discovered that the icon was popping up for everybody. In the video below you can see the bug.

It took some trial and error to run something only in the desired client but I manage to do it by changing these nodes.

This affected everyone

This affected everyone

This only affects the client that trigger the function

This only affects the client that trigger the function

In the images above you can see the function that sets the icon visibility (in the previous version I used visibility and in the new one I used Hidden in Game but it shouldn't make any difference during replication). This function is executed when an character overlaps the hoverbike ride collision and tells the bike that someone is near to ride it.

To make it work, I just needed the character reference that triggered this function and compare it with the player pawn. The get player pawn node will return the local pawn and will only be equal to the character reference if the hoverbike version is the local one.

And now this is the status of the hoverbike

In the next development log I will show how I fixed the replicated movement of the hoverbike. See you soon!

 

Hoverbike Multiplayer Development Log 1

Hello! I'm Ramanand aka Ram one of the programmers in Unforgiven and due to the massive request to add replication / multiplayer to our Hoverbike System we at Unforgiven have decided that is time to do it . This is something I've been wanting to do since last year but didn't have the time because of university related stuff but now that I have graduated I find myself with more time in my hands.

This series of articles will be focused in the addition of multiplayer to the Hoverbike System you can find here in the Unreal Marketplace. It’s not a tutorial because I’m not an expert in replication in Unreal Engine (yet) but is a log of the steps I did to make the replication work for the Hoverbike. I'll try to show most of the things I did that worked and do my best explaining them but if something is not clear you can ask me in the comment section.

As learning material I used the Unreal Engine documentation found here and this Unreal engine stream that you can watch here.

Week 1: Testing what works and what doesn’t

My first step to tackle this project is to check how much does the hoverbike system breaks when I try to use it for multiplayer out of the box. First set up the number of players to 2 and play around the level to check which problems arise. The player movement is controlled by the Character Movement Component so we don’t have to worry about that. 

Changing the number of players used in the PIE

Changing the number of players used in the PIE

Initial problems detected after testing:

  • Client can’t ride correctly the hoverbike
  • Animations are not replicated
  • UI behaves incorrectly
  • The destruction of the hoverbike because of the damage done to it cause the player mesh to disappear

This test was done in 10 minutes so there is a high probability that I missed something. Don’t worry though because the development is iterative so test will be done exhaustively in order to ensure the best quality we can. I’m doing things this way because the time I give to this project is around 2 hours a day so I rather see results quickly and polish them gradually.

Let’s start by addressing the most important issue “Client can’t ride correctly the hoverbike” which means that the client isn’t telling the server that is riding the bike.

Mount and Dismount

To solve this we have to open the ‘BP_RiderComponent’ and check the ‘Component Replicates’ checkbox under the ’Class defaults’

As a little background, let me explain that to for a pawn/character to use the hoverbike you just have to add the ‘BP_RiderComponent’ and set up some inputs and that’s it. So this actor component plays a large role for the hoverbike to work.

Next we have to edit the ‘BP_MyCustomRider’ to use replicated events (also called RPCs in c++). Following Epic’s standards I created a custom event called ‘ServerMount’ that Runs on the server and is Reliable. I used Run on Server because the possess node needed to mount the hover bike only runs on the server and I checked Reliable because we always want this to happen, otherwise the engine may skip this if there is heavy load on the network.

After this we have to call the ‘ServerMount’ when the input is pressed. So we replace the current mount function to our replicated one.

Old

New

Our ‘Bp_MyCustomRider’ should look like this after applying the same process

For the dismount, we need to edit the BP_Hoverbike because its there where the event is called. We create another reliable replicated event that calls the dismount in our rider component.

Screenshot_223.png

Now we need to fix little things like the bike being able to be mounted by more than one player now that we have replication in the project.

And that would be it for this week, next time I'll check the problems the animations give us and some movement problems I encountered along the way.

Tutorial: How to make Spinning blade using Blueprint


Hey! I'm Ram, Unforgiven's programmer. Today, I wanted to share a little tutorial with you guys, because it shows some interesting concepts that you might use while working in the unreal engine. This blueprint is a part of the new Customizable Deadly Traps, which is coming up soon for Unreal's Marketplace.

Here, I'll talk about timelines, events and instanced static meshes. First, lets see what we are going to accomplish :

Normal spinning blade trap

Any number of blades

Initial Setup

Lets start by finding the meshes that we will use. We need the base of the trap and the blade that will be spinning. You can use the meshes that I used as placeholder when making this blueprint. ->Blade mesh<- and ->trap mesh<- (Click to download)

Now that we are ready to create the blueprint, we will create an actor blueprint with a static mesh component and an instanced static mesh inside.

Change the static mesh in both components.

Change the static mesh in both components.

Also let's set the z location of the blades to 153.

Construction Blueprint

Here's the picture of the construction blueprint

Click image to see it in full size

It won't work properly, but you can use this pastebin as an starting point of the construction blueprint if you don't want to start from scratch, just click on download raw and then copy and paste it in the blueprint.

In the construction blueprint, what we want to do is set the blades up, and also the collisions, so we can do something when a pawn overlaps any of the blades. To start with it, we are going to create a integer variable with the name NumberOfBlades that will be used by the for loop to help us add as much instances of the blades as we need. Set the default value of this variable to 1. Also create a vector variable with the name ModifyBoxExtentBy and a default value of (0;0;0) just in case we are not satisfied with the box collision extent.

Spawning the blades is easy!

What we need to keep in mind is the rotation and location that we are going to use to spawn each blade, since our blade has the pivot at the side we will only worry about the location. Using simple math we take 360 and divide it by the number of blades we have. (ex. 1 blade -> 1 blade with 360 rotation, 2 blades -> 1st blade with 90 rotation and 2nd with 360, etc).

After spawning the blade it is necessary to attach to it a box collision component so we can do something when the blade hits a pawn. Now that we set that up we find ourselves in this problem.

If we use the same transform for the collision boxes it generates a problem, because the pivot for the collision box is in the center.

To solve this problem, we are going to use polar coordinates.

θ is the angle in the image

θ is the angle in the image

With that settled all we need to do is the conversion from polar coordinates to Cartesian coordinates.
That marks the end of the construction script!

Event Graph

In the event graph, the first thing we are going to do is to create some variables that we'll be using for our next step:

  • Bool IsOn | default value = true | If true the trap will start active.
  • Bool IsSpinning | default value = false | If the blades are spinning at full velocity this will be true.
  • Float RevsPerSeconds | default value = 1 | Revolutions per seconds.
  • Float TransitionRate | default value = 1 | Play rate of the transition. Greater number = faster transitions between on and off.
  • Bool UseIntervals | default value = false | If checked the trap will be in the on state for an interval of time before switching off. This behaviour is used for the on and off states.
  • Float StateTimeinterval | default value = 3 | Time in seconds that the trap will be on or off.

Now lets take care of the event that is going to fire every time a pawn begins to overlap a box component created in the construction script.

Event BeginPlay

Click image to see it in full size

What we are doing in the event BeginPlay is going through the CollisionBoxes array and binding an event to OnComponentBeginOverlap, then renaming that event to HittedSomething. When fired, the event HittedSomething will cast the actor to a pawn and if the cast is successful it will execute anything we want.
After the loop is completed we will check if a boolean called IsOn is true and if it is, we will call a custom event named TurnOn.

Event Tick

Click image to see it in full size

In the tick event, we will apply the rotation to the blade(s). With a branch node we check if the trap is On and if it's spinning. Then we proceed to add the relative rotation to the blades in Z. Multiplying the RevPerSeconds by 360 gives us how much rotation should we add in a second and multiplying that value by the delta seconds gives us how much rotation should we add every tick.

Custom Events TurnOn and TurnOff

Right now we have a working blueprint that spins if it is on and when it hits something an event fires but there is no smooth transition between the states on and off. So these events are going to help us in that task and also provide us with a way to easily change the states during execution.

Click image to see it in full size

Let's look at the event TurnOn first. This event sets the isOn variable to true and then uses a for each loop to activate the collision of all the collision boxes. When this loop is completed the timeline named TurningOn will play from start.

One point at time 0 and value 0 and the other at time 2 and value 1.

In each update of the timeline we will add relative rotation to the blade and when it is finished the direction is going to be checked. If the direction is forward it means that the blade was in a off state, is turning on and now its at full speed so IsSpinning should be true. Also we should disablethe collision of the blades because if they collide with something they are going to cut it and not bump it.
Finally, we check if we are going to use intervals, if we are using intervals the time will be set through a delay node that will call the TurnOff event when time is right.

The TurnOff event will be similar to the TurnOn event but with minor changes. instead of playing from start the timeline will reverse form end and when it finishes we will set the variable IsSpinning to false, enable the collision of the blades and disable the collisions of the boxes.

And that's it!


Now you have everything you need to make your own Spinning Blades using Blueprints.

If you liked this tutorial, give us a like, share it with your friends and let us know what would you like to see in the future for more tutorials!

:D

Unforgiven Team
Ramanand

 

On Development: Ready Platform Go! - Unreal Marketplace

Hey, everyone! we are now working on some cool new packages, this one is our solution to creating platforms for any game that you are working on. It will be coming soon to the Unreal Marketplace, so stay tuned!

I will share with you some pictures and features to let you know what is it about!

Features:

  • Use Splines to create the platform trayectory.
  • Setup number of uses.
  • Activate Falling platforms and set their time before falling.
  • Use falling animations.
  • Toggle between movable or static platforms.
  • Activate them automatically or when you step on them.
  • Set the travel duration.
  • Set waiting time and toggle the "Wait to step on it" feature.
  • Activate loop travel and toggle closed loops.
  • Use Particle System trail.

So what do you think? is there anything we are missing?

Let us know in the comment box below!

See ya!