Dynamic hexagonal tile based level creation (Unity background)
Hey everyone! I'm from Unity game engine background (3+ years of experience in unity engine) and I'm trying to learn Unreal engine. I want to create level dynamically after receiving/reading level information (2D array). The workflow in unity: I can create one Hexagon block and make it as a prefab. (I had to write script that generates the hexagon mesh and save it as asset since there is no direct way to create hexagon in unity.) This prefab can be assigned to a public variable in C# script and through script I can instantiate the prefab as GameObjects and place them where ever I want. This is how the sample level looks in Unity game engine. I want to know the work flow regarding the same in Unreal engine. As far as I read about Unreal Unity comparison, prefab in Unity engine is almost equal to blueprint in Unreal engine. But I made the hexagon block in unreal using BSP (which is really easy just one click and done). But there is no option to make this as blueprint. It is showing that this is already an actor and there is no option to make it into blue print. :( I want to know how i can make a hexagon block that can be instantiated at runtime in C++. I am very new to unreal and tutorials (shows blueprints in middle) are confusing me. So I thought of learning Unreal but making a sample level instead of watching tutorials and getting confused.
asked May 01 '16 at 12:15 PM in Using UE4
I managed to do create this and for anyone who just started Unreal and looking for answer.
Step 1: Create the BSP in any shape you want. I wanted a hexagon so I created a cylinder BSP with 6 sides and applied the texture to it. In details panel (click the small arrow button at end of the details panel), click "Create static mesh" and select folder where you want to save this asset.
Step 2: Create a blueprint actor class. Click "Add new" button in content browser and select "Blueprint class" and select Actor and name this actor anything. Actor can be a visible object in level or invisible script only object on which only code runs. Double click the created actor in content browser, it will open the blueprint editor. On top right, click "Add component" and select static mesh.
Step 3: In details panel, select the static mesh that you saved in previous step.
Actor is ready now its time to set up the function that can spawn this actor in the world at a particular position and return the AActor pointer.
Step 4: Create a C++ actor class and I called that "LevelCreator". Add a function like this to this LevelCreator class.
Drag and drop the level creator into the world. This will be the kind of actor that has no visual element at all but only code based actor. Right click on the LevelCreator in the C++ class and select "Create blueprintclass based on LevelCreator" and name it as "LevelCreator_BP". this will create a blueprint actor with ALevelCreator class as its parent. Double click the LevelCreator_BP to open it in blueprint editor.
Step 5: Mouse over the function panel and "override" button will appear. Click on the override and select the function "SpawnFloorBlock". It opens up in new tab.
Now use the blueprint to spawn the actor at particular position and return the actor.
You can use this function in both blueprints and C++.
answered Jul 01 '16 at 09:59 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here