Becoming discouraged by UE4 Coding.

Not because it’s C++…

but because it feels like everything works “together” or not at all.

When I look at any simply tutorial or setup…it always seems like everything is so integrated that either everything works or nothing. I’m not sure if im doing something wrong or if there’s a more direct/simple way to do things…

There is probably some truth to the “it either all works or nothing works” statement because we do provide a game framework that includes several pieces that all work together. Once you get the hang of it and figure out how the pieces fit together, it becomes much easier.

What exactly are the things you’re having trouble with? We would love to try to give you pointers to get you going. And it helps us (me personally) know what areas we might need to focus on in the documentation and with tutorials.

Yes, that can be daunting.

Break things up as much as possible until you’re familiar with things.
For instance, create a basic C++ project, rather than usin the first person or third person template.
Then just do a few minor things here and there to get aquainted, based on snippets of code from some of the examples.

Change the players speed.
Increase the jump height.
Add a walk/run button.
Stuff like that.

It’s hard to explain…

I can read example code and understand somewhat what it is doing, but when I try to sit down and code something myself I feel really overwhelmed. I feel like I’m supposed to use all sorts of inherited classes, but I don’t know what all of those classes are.

What I’d like to do is almost built something separate from the game engine and add the engine classes as I need them.

In another game engine (which won’t be named) I coded a behavior based AI system where any number of agents would communicate with eachother using a centralized AI Controller (stored references to all of the spawned Agents, ran distance checks and such) along with code based detection system using direction and angle from forward vector to find if they were in a cone in front of the Agent.

In UE4 I tried to replicate the basic AI behavior and the best I could do was get them randomly pathing through the use of a behavior tree and blueprints (no code). I could PROBABLY replicate the behavior through the use of strictly blueprints but I realize that eventually I’m going to need to code something…so best I don’t avoid it.

I guess my biggest problem is figuring out where I’m supposed to start if my goal is to code something to be used in the game.

For example…If I wanted to create an enemy. I would need:
Simple variables to define the enemy like health and movement speed - this part is easy.
The ability to move (add code to project “Character” for movement)
Do I need to cal from AIController?
Reference to player(s) through a pointer or an Array (for many players) in order to check detection on player

To handle multiple AI and grouping I would need to:
Create a Controller that stores references to all enemies in a Linked List
Run a check on all enemies against each other on a defined rate (nested for loop) to check distance…if distance < certain amount they are close enough to interact

I also had leader-less grouping system in other Engine which basically spawned a Group controller to store references to all grouped Agents. Each group has 1 Controller.
These would destroy/create and set referenced objects as “Grouped” so that they would stop looking for a group.
Pathfinding was performed on them as normal, However, when any of these “Grouped” members completed their path, they would send a message to all other Grouped members to find a new path to a random point in radius around the next target position.

Also the need to re-open the editor every time I compile my project (which I understand is simply part of c++ projects)

It sounds like you will be able to accomplish this in UE4, you have a pretty clear breakdown of what you want to do.

You don’t need to use the built in Behavior Tree system as in the ShooterGame. The Strategy Game demo goes about the AI in a different way, and shows how in code you can control the animations.

Basically, you need a pawn (you probably want to extend from character to start ) , and you need a class that extends from AIController. If you don’t want to use the BT stuff you’ll need to use tick is some way when building your system whether its and FSM or Utility System. There are several threads up regarding getting started with AI in UE4.

Here are some links that may help.

This was my thread on the BehaviorTree that some Epic Devs responded to and gave good information. My post is not the best way to do BT’s but it got things started, and it does function that way.

In this thread, there is a very clean example of setting up BT’s in either Blueprints only or in conjunction with C++, and as well two simpler systems for doing AI. Scroll down to the post by Lukasz.

I think I was jumping a bit too far ahead of myself and only seeing the end point. I was making it way more complicated than it needed to be.

I messed around with the behavior trees based on your thread and another. However, I had problems setting the Keys on my blackboard. If I have more than 1 key it doesn’t seem to set the Keys properly.

I think another thing that I’m still getting used to is Blueprints…What should I code and what should i whip up with Blueprints? I always end up sidetracked from coding and messing with Blueprints…

its called being overwhelmed with information.

in a situation where you know what to do with coding you know how to approach it, control it. and manipulate how you deal with it…

now its taken all that you knew and twisted the information in a new way… its all still there… plus tons of new stuff with new features… the problem is your not use to approaching it this way so your at a loss… thus your thinking of going back to what you know. it will take time but you will adjust just as you did when you first started coding.

Yes…definitely information overload. When I stepped back and re-focused on the basics (after I made this thread) I realized that it really isn’t all that much different. The biggest thing seems to be: Figure out which classes you want to inherit from and read the documentation to find which functions are available.

So for Behavior Trees…I would basically setup a Blackboard to define the Actor. The Actor’s class would contain functions to access variables on the Blackboard. The Blackboard variables determine the behavior and routing on the Behavior Tree.

I do have one question I’m somewhat stumped on. With Blackboards, how do you determine which Key you are setting using “Set blackboard value as ____” if you have multiple keys on a blackboard? I couldn’t figure out how to do it in Blueprints and figured there may be a more intuitive way to access them from code.

It happened to me on UDK, why i only knew basic coding, so i could read code but not really write it.
I overcame that thing by stepping from udk, and started coding a simple pong clone in SFML, and a platformer in 2d. After that, my programming skills were much sharper and everything “clicked” together.

I was in the UE4 Beta, when I started my project last year Blueprints did not look like they would serve my game design, it was too far out of the box for what I wanted to do, and AI is key to my game. So, I dove into C++ and worked with it that way. My dev team is tiny, it is myself and 1 artist basically, and this is a nights and weekends project. I was able to get the core functionality I wanted in C++, first by writing my own AI system, a Utility System, then I switched to using the BehaviorTrees, but from C++ looking at the ShooterGame as an example. Then when UE4 released publically I had issues porting my project code. Looking at all the added Blueprint functionality, especially the Blueprint comms, interfaces, and Blueprint Behavior Tree’s I decided to switch gears on my project and go Blueprint only ( at least for now ). It took about 1 day to redo my project from C++ into Blueprints, and since added in some features that weren’t present before. My other reason is that I am figuring that updating the project to the latest patch or release will go smoother than if I was using C++, or compiling the engine myself. I tried it out, but for my game I really don’t think I need it and it is time consuming to merge code and integrate engine changes.

That’s my reasons for deciding to go Blueprint only for my game.

Yep, new powerful system to learn + very young interface = steep learning curve. I learn by example more than by reference, so moar video tutorials are the way to go for Epic. Or when the community will be more mature (with the engine :smiley: ), tutorials will appear by themselves.

The way I first learned was to break things that worked and then try to rebuild them, tweak something here or there, and keep trying until I more or less got a sense of how things fit together. Eventually you’ll build enough understanding and confidence to venture off the beaten path, and even further on you’ll realize just because things are done a certain way doesn’t mean that’s the best way to do them or at least the only way they should be put together.