To get to know how functions work in Unreal Engine. I had to know what Blueprints are and what they're utilized for in game design. Blueprints are a vital component to the Unreal Engine software, they act as a component to function actors and actor classes. However, this is where things get a little convoluted to explain for actors. An actor class is not an actor.
To start off I opened a new project, I selected the floor asset, created a blueprint from the floor. In the 'details' panel I went into "transform" window and selected "static". Back to the 'play' window I selected all of my actors, right clicked and did "convert selection to blueprint class". Then I opened the level blueprint.
Inside the "event graph" I created a new event function called "Event BeginPlay". Then I created a "Print String" event function inside the component "In String" I added a string message called "Hello World". Then I compiled the blueprint. Back to the play console window I wanted to make sure the blueprint worked so, I played the game and it showed the words "Hello World" on the top left hand side. Then I added a new message called "I am a floor" (located inside the event graphs "Floor_Blueprint" blueprint file.) I went back into the console play window once again it played and it showed the following message: "Hello World" "I am a floor" Back in the "event graph" I dragged out the execution pin to create an event function called "Delay" delay will hold a function within a certain time frame for how long its held back for. With delay I wanted to delay the next message after the "I am a floor" message for 2 seconds. I went back to the play window and it showed the messages on top left screen of the console. Then back in the event graph I created the " A keyboard" event function. Inside the "A" component I dragged out the "pressed" execution pin to print a string. That print string's message is "Hello" but I changed it to "A" has been pressed. For the "released" component of "A" its print string message is called "A has been released". Whilst testing I forgot to compile the code so i went back and compiled the blueprint. Then it showed that I had pressed or released "A" in the message log.
In "Minimal_Default" blueprint's event graph I copied the commands that are in "Floor_Blueprint" event graph. Back to the "Floor_Blueprint" event graph I added a new "W keyboard" event function then I dragged out the "pressed" execution pin to get an even function called "AddActorWorldRotation". I changed the delta rotation of X from "0" to "5.0". I also copied the "W keyboard" and "AddActorWorldRotation" event functions a couple times. I changed the copied "W" key input to "S" and changed the "AddActorWorldRotation" Delta Rotation components X from "5.0" to "-5.0". The next thing I did was creating a reference to "Floor_Blueprint" that ""Floor_Blueprint" is used as targets for "AddActorWorldRotation's" event graph. Back into the play console I tested out the "W" and "S" keys and they worked. Back in the event graph I added the "A" and "D" key board input event functions. I tested the "A" and "D" keys in the play console window and it worked.
Overall this provides good insight and depth about blueprints in Unreal Engine. An important and essential coponent to use as its a way to code and program your assets.
Comments