Andrew Booth 3D
  • Home
  • About me
  • Still Life Project
  • Twitter
  • Linkedin
  • Archived Blog

Setting up spawning functionality pt2.

8/16/2018

0 Comments

 
As shown in the previous post I created a 'for loop' which fired an custom event named spawning. As you can tell from the attached images; that event fires logic for spawning functionality. First I got the child class I created in 'Asset Handier' blueprint which an array containing the asset blueprints ready to be spawned.  The reason of using class type variables is because the 'spawn  actor' node only spawns actors from a  class. From this array of classes I used the 'length' node which returns the index value total of elements within that array as an integer (Fig1).
Picture
Fig1.
Picture
Fig2.
 This value I used the max input for a 'random integer in range' node which randomly picks a integer between a min and max values. I used this random return value to drive a 'get' node (which gets a single value of an array)  from my 'child class' array variable to the class input of the 'Spawn Actor' node (Fig2). This means the logic is random selecting an asset from the index of the array then spawn that into the world.
Picture
Fig3.
Picture
Fig4.
From the return value of the 'spawn actor' node; I used as a target for my interface event to pass through some data to that spawned actor and fire logic in that asset. I am using interface as a main way of blueprint communication so i can pass data between different blueprints. Using this methodology is most efficient since I'm using logic to set up certain requirements before the door into the next level. I also took the 'spawned amount', add one to that amount and then setting the 'spawned amount' so that the beginning of the loop knows how many assets spawned until the max amount of assets is spawned have been reached (fig3.)
The problem with this methodology is that the 'spawn actor' requires a transform input values so the game knows where to spawn the actor. To get around this I added a box collision component (Fig5) to act like a container where I can tell the game to spawn inside the collision.
Picture
Fig5.
The problem is that although you could get the world transform of the box collision but it wouldn't properly spawn inside the box to how I need it for the game as it will give the overall location not a pin point value to spawn and it wouldn't be random. In figure 6 shows how I got around this. I used a 'get component bonds' node which literally gets the origin (center  of the box) & box extent  values of the box. The math logic in figure 6 looks complex but the methodology once broken down is quite simple. The ideal is basically to break the vectors of the component bounds into float values; then working out the min & max values of both the X & Y axis between the origin and the box extent. Then feeding these min & max Axis' values into 'random float in range' nodes that is used to make a location vector from the X,Y and Z axis values. To simply put I used the 'random float in range' to randomly generate a random pin point location between origin & box extent of the collision box. To finish up I used a 'make transform' node; taking values from random generated rotations and scale values (fig 6) along with the location vector to make a Transform value which is used for the transform input of the 'Spawn Actor' node (Fig2.).
Picture
Fig6.
0 Comments



Leave a Reply.

    Author

    Write something about yourself. No need to be fancy, just an overview.

    Archives

    August 2018
    July 2018

    Categories

    All

    RSS Feed

Powered by Create your own unique website with customizable templates.
  • Home
  • About me
  • Still Life Project
  • Twitter
  • Linkedin
  • Archived Blog