Creating my own AI Bots

So first, I’ve gotten too use to Unity where the code was simply put into little self contained scripts, such as this little guy done in C#

using UnityEngine;
using System.Collections;

public class EnemyAI : MonoBehaviour {

	private Transform target;
	public int moveSpeed;
	public int rotationSpeed;
	public int maxDistance;

	private Transform myTransform;

	void Awake() {
		myTransform = transform;

	// Use this for initialization
	void Start () {
		GameObject go = GameObject.FindGameObjectWithTag ("Player");
		target = go.transform;
		maxDistance = 2;
	// Update is called once per frame
	void Update () {
		//Looks at target
		myTransform.rotation = Quaternion.Slerp (myTransform.rotation, Quaternion.LookRotation(target.position - myTransform.position), rotationSpeed * Time.deltaTime);

		if (Vector3.Distance (target.position, myTransform.position) > maxDistance) {
			//Move towards target
			myTransform.position += myTransform.forward * moveSpeed * Time.deltaTime;

Now I’m actually attempting in translating that simple AI code into UE4, which is actually quite a challenge I’m facing. Though it would be a good base to actually start programming but I’m finding it a bit harder to get comfortable then I was hoping it would be. I’ve ran through the documentation and such and I have been trying to dissect the Bot code from the Shooter Game sample that they have. What I’m really facing in trying to accomplish this little task in the wrapper and skin of the UE4 coding structure. I was mainly hoping if someone could help explain the little nuances of coding in the program, or had time to explain a few key things in when I’m attempting to write my own code for UE4. I have to get out of the mindset of programming for Unity!

Any tips, hints, suggestions or pointers?

I recommend you look into Actor class as a starting point.

Below is a link to a wiki article that was started to help those coming from Unity that may not be familiar with C++ and also talks about equivalent functions between the two engines.

This stuff would probably go in a class extending AIController.

Your variables go in the header. the .h file.

I don’t think you need the Awake function or the transform it’s referencing. Get the ControlledPawn and the Location.

The code your doing in Start would be in BeginPlay:

The things in your Update function go into Tick.

Ah, those links are really helpful. I hadn’t programmed in C++ for a bit close to a year so the guidance is really helpful.

Very helpful link! Thanks a ton for that, it’s actually clearing up a bunch of transitional confusion I was having.

Again, very helpful. The direction is much appreciated and the breakdown of where each part of the code would go is going to be very useful for other codding projects.