Non classé

Interaction

On my latest game project, I designed a new interaction system. To make my character able to interact with the environment, I use a system based on mainly three classes.

– InteractionComponent
– AAction (with some ADecorator)
– Int_Touch

unityInteraction

 

InteractionComponent

This script is attached to the character, it manage the interaction and the different suitable action.

This component has a list of targets.

AAction

Derived in Act_Open, Act_Describe, etc… this script define a capability. Each action has one or more Decorator, which are basically condition in the form of a script.

Int_Touch

This script make an object interact-able by a touch. Whenever the character will be in the trigger collisionBox of this object, it will be added in the target list of InteractionComponent.

 

How does it work?

We have on the level a GameObject with an Int_Touch script and a Key script.

Thanks to the Int_Touch, the Key will be added in the player’s InteractionComponent target list.

The player will then press the « use » button, which will trigger the ProximityInteraction function of the InteractionComponent script. This function will go through every action the character is capable of, and try each of them.

In this case, the character as a Act_Pickup action, attached with a decorator Dec_IsClass. For the Try to be a success, the target must have a component of the type specified by the decorator Dec_IsClass, which is here Key. The condition of the decorator being met, the action Act_Pickup is valid and will be launched.

And, voilà, the key is picked up.

 

Demonstration

Link to the github project page.

 

I created a quick project demonstrating this system. I took several script from my main game project and simplified them. The demonstration is meant to be played in editor, and the more important part are the script. For the purpose of explanation I heavily commented the different script, so feel free to have a look.

The project is available on my github at this adress, you can either clone the entire repository or pick the script files.

To make it work, clone the repository with the Assets and ProjectSettings directory. Launch Unity3D and choose to open a project, select the directory where Assets and ProjectSettings are. And you are good to go.

Thanks for playing!

 

Non classé

Behavior tree

In my latest project, I tried to implement a behavior tree for my AI.

I first discovered the behavior tree system in the Unreal Engine 4, which has a full graphical interface to easily create behaviour trees. And as it was quite a neat feature, I wanted to try implementing my own in Unity3D.

A link toward an article on Gamasutra about behavior tree

I first created a Node class, from which the Selector, Sequence and Leaf class would derive from. Each of those class contain an array of following Node, allowing to navigate in the tree.

A class Decorator would act as a « if », and when arriving on a Node, it would first GetComponent<Decorator>(), meaning : look for every script of class type Decorator, and test them. For example, I created a Decorator_HasRangedWeapon, or Decorator_IsHurt, etc…

For each new need, I just have to create a children of Decorator and override the Try() function which, well, try if the condition is met.

In the end, it worked quite smoothly, even though for now I don’t have yet very complex trees.

Below a Selector type Node, with two decorator. If the character controlled by the AI has the required PsyStat and has a weapon, the Node will be considered a success and pass to the next Node (Melee)

BT.PNG

Non classé

Back to Unity3D

And this time with 2d horizontal side scrolling rpg!

Unity3D is one of my favorite game engine, mostly due to its affinity with the ECS (entity component system) thanks to the scripts.

For this project, I created a script for each capability, as opposed as a more parent-children system where a class would hold all the capability needed. For example a script which manage the health of a character, an other the movement, etc…, etc…. With each script as independant as possible. In the end, to create the player character or even the monsters, I just have to pick up in my script library the different module or system and boom! Character done!

unityECS.PNG

As you can see on the screenshot, the number of scripts grows rapidly, but well, it can be perfect 🙂

Also, I still use derivation, because it is still awesome and necessary for many cases.

Non classé

How long will it take…

Recently I worked on an exercice about timing, the global idea was simple :

« Take an existing game, make propositions to make it better. »

With only this sentence, I can already here the feature creep greedely crawling toward us, but, and here comes the subtelty of the exercice, those propositions should be as cost efficient as possible. And you have 48 hours.

Here, being cost efficient means that a feature should be balanced between quality and cost and difficulty of production. Meaning that even the best awesomest proposition wouldn’t be ideal because it would cost too much to do. In comparison, a simpler and cheaper feature, but bring enough quality is better.

This exercice is all being as accurate as possible in the estimation of the quality and difficulty. To do so, I created a google sheet a made a ranking with my proposition. The ranking being the ratio cost/quality. Using a sheet made it quite easy to sort all the proposition and make quick modification.

sheet

And if estimating the cost is quite difficult, it was a truly interesting exercice.

Non classé

Unreal Engine 4 Training #2

Time to break some stuff!

In the tutorial there is a part where you put some collision on your projectile, and I had some difficuties with it.

The modification made programaticaly werent taken into account, for example, I set the InitialLifeSpan, but it was not added on my projectiles until I set the value directly in the editor.

I had the same probleme with the collision, and once again I had to use the editor to set the correct collision values.

Or maybe because I was using the BP_FPSProjectile has Projectile and not the FPSProjectile directly. I should dig a little more on this matter.

Anyway, here the result, the cube was sent flying by the might of my projectiles 😀 Unreal Training_2.PNG

Non classé

Unreal Engine 4 FPS Shooter C++

It’s been some times I’m working with Unreal Engine 4, mostly with the blueprints however (they are so powerfull! ><).

When working on this tutorial I met some error in the documentation, so here is an article with the problem encountered and there resolution.

Unreal Training_1

The first part was rather easy, the only difficulty was the part in Changing the camera view which seems deprecated :

FirstPersonCameraComponent->AttachParent = CapsuleComponent;

This didn’t worked for me, I had to use the following line :

FirstPersonCameraComponent->AttachTo(GetCapsuleComponent());

Once the character set up and ready, I worked on a projectile mecanism. The most difficult part was to understand and then set up correctly the colision profile for the projectile. Once done, I played a little bit around with physics and then added some health to a MobCharacter and make it go down for each hit taken.

Unreal Training_2.PNG

And I stopped there for this tutorial. Next time, I will probably work on an infiltration system.

GameDesign, Programming, Unity3D

LocustReign #1

This project is my latest creation. It is a 2D side scrolling RPG set in the Dark Horse, Dead City universe. And that is as much as I can tell you.

Not because it is a secret project and derp derp but because I didn’t have figured out exactly  what this will be yet. I started designing the gameplay two weeks ago, and I tested a lot of ideas, mainly for the battle system but I’m not completely satisfied.

For now I’m on a turn by turn card based system, I’m currently prototyping on Unity3D and the new UI system is greatly helping me. It was so much pain before! Thank you unity guys!

LocustReign_1.PNG