How to make a Spider in UE4 Part 3

In this 3rd installment of the make a Spider blog. In the last part I left off with some problems. Some things worked great and are keepers, but the movement simply wasn’t working right. The spider could detect any wall, but once it rotated up onto it, it’s orientation was wrong. I had used the Character class as the base, which comes with a collision capsule component which always want’s to be upright.

This already wasn’t working out for the spider, a rectangle is a much better collision shape but extending the Character the capsule is hardwired into it. While I was able to get the spider to walk up the wall, making it rotate on the correct axis was different for each wall it was on, and that was because of things hardwired into the Character.

The best option going forward, instead of trying to hack the Character is to extend farther up the chain, from Pawn directly. The Pawn doesn’t have any existing movement code to fight.

Even though this is going to be an AI controlled spider, for developing the movement it’s a lot easier for it to take it’s control from key presses. Saving the path-finding problems of walls and ceiling to deal with later, after the spider can move on those surfaces well.

So, I started a new UE4 project from the launcher. A BaseCode C++ projectile.

PawnSpider

I made a new C++ Class extending Pawn and named it SpiderPawn. Then made a new Blueprint extending from SpiderPawn, naming it SPiderPawnBP, made a scene component, named it root. Then added a SkeletalMesh component. I dropped my Spider FBX, mesh, Idle, and Walk files into the project, imported them, then set the Skeletal Mesh to the FBX I had just imported as a SkeletalMesh.

So now there is a reasonably blank starting point to work from. Because the trace system from the previous posts was working well I will add that into the new Pawn.

There is a design decision for the movement that needs to be made. The last version of the spider had problems because it was trying to do to much.

To start with just 2 movement controls, walk forward and rotate. Once things are working can always add to it.

I will make the functions to move public to start, and in the level blueprint handle the key press’s and call the functions on a reference to the Spider in the level. Once things are working, will restrict there access and call them from a AIController which is possessing it.

Share Button

Leave a Reply

Your email address will not be published. Required fields are marked *