BGP 2015 – Second week: Swithcing to Unity3D 5 & First playable

unity3d1

Hello!

This week we decided to switch to the Unity3D engine. The reason for doing this was because we programmers could not find a way to make a custom gravitational effect work with the player movement because of how Unreal handles forces in relation to character controllers. We programmers were also inexperienced with the Unreal engine, which was also a factor.

We do both have experience with working in the Unity3D engine however, so after talking to the rest of the group about it the switch was made.

Unfortunately the other programmer in the group came down with the sickness so it fell to me to make the new gravity work as well as the input and movement mechanic for the game as the deadline for our first playable was this Friday.

The road segment that the player is pulled towards via the gravity effect is determined by trigger colliders. This currently has a problem whenever triggers overlap as the game switches to its default gravity whenever a road segment’s trigger collider is exited.

Through iteration I was able to create a finally create a gravity effect on road segments by taking their Transform.up vector and inverting it. This way it does not matter which way the road segment is turned or rotated, as long as the player is on the right side of it and close enough to it there will be a gravitational pull towards the current road segment.

I still do not know how to handle road pieces that curve tough I am thinking about attaching invisible objects to the road segments and using them as the gravitational center instead of a Transform.up vector.

Using a raycast straight down from the player to determine if there is a custom gravitational pull would be an alternative were it not for the fact that players that are rotated the ‘wrong’ way should still be affected by the gravitational force as long as they are close enough to the road segment.

ProjectSteelFirstPlayableScreenshot

As it stands a first playable is done, however the gravity effect and movement still needs more work.

Cheers!

BGP 2015 – First Week: Learning the Unreal 4 Engine

unrealengine4logoHello!

This week I’ve been doing research on the Unreal 4 engine. This is the engine that will be used to make our game, so I’ll need to be as familiar with it as I possibly can, at least the scripting part of it. The game my group is making is a racing game that takes inspiration from F-ZERO, Wipeout and Distance.

I started out learning about blueprints and how they can be used. Blueprints are a visual form of scripting built into the Unreal Engine. It can be combined with normal scripting in C++ and indeed any script you make in code can be made callable in blueprints. I learned about blueprints mainly from tutorials and documentation on https://www.unrealengine.com/. It took a while to get used to but after roughly a days work I started to feel comfortable with how the blueprints worked.

I then moved on to trying to learn how to make functions in C++ scripting that could also be used as nodes in the visual blueprint scripting. It took quite a lot of effort since most tutorials and documentation on the subject, be it official or not, said pretty much the same thing. They stated that all that was needed in order to make a function callable in blueprint was to write UFUNCTION(BlueprintCallable) just before the function declaration.

Like this:

//Fire a Weapon

UFUNCTION(BlueprintCallable, Category=“Weapon”) void Fire();

(example taken from https://docs.unrealengine.com/)

However this did not work for me and I could not figure out why. Eventually, after a lot of searching online and asking fellow students about it, I stumbled upon a post in a forum where a person described the same problem. Turns out that, in some cases at least, you need to restart the Unreal Editor in order for the functions you’ve made blueprintcallable to show up. For some reason, this was NOT in the official documentation.

Once this was sorted out and making functions that were blueprintcallable no longer posed a problem I started making sample projects following tutorials for making racing games as well as downloading and going through sample racing game projects for the Unreal Engine. I was mostly focused on how to code input, either in C++ or blueprints, and what kind of  movement system should be used for our game.

At first I was considering using the vehicle movement that is built into Unreal 4 but it is meant for wheeled vehicles and seems to need to be attached to an object with a model that has four wheels. In the racing game we’re making the vehicles are supposed to be hovering pods powered that are propelled by rockets or jet engines. With some research i found out that there is a type of component in Unreal, called physics thruster, that can be attached to an object to propel it. This worked out somewhat well, I could attach thrusters to an object and bind their activation to player input. However, with this I was not sure how to measure the speed of the object or how to control the acceleration and max velocity. In addition, for each pod vehicle we made we would have to physically place the thrusters and give them a suiting force. If their placement is off, then so will the thrust be. So I looked around some more.

Eventually I discovered that the component for regular character movement has some variables for deceleration and ground friction that I could manipulate in order to make the movement seems less like walking and more like driving. With this I actually can control things like acceleration, max speed etc. Though it still requires some work, this seems to be the movement model we will make use of for our game. The next step will be to start building our first playable.

Cheers!