<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" >

<channel><title><![CDATA[Amerigo Moscaroli - Game Programmer - A Crack in Time - Dev Blog]]></title><link><![CDATA[https://www.amerigosportfolio.com/a-crack-in-time---dev-blog]]></link><description><![CDATA[A Crack in Time - Dev Blog]]></description><pubDate>Tue, 21 Feb 2023 01:44:13 -0800</pubDate><generator>Weebly</generator><item><title><![CDATA[Player Attacks Part 3]]></title><link><![CDATA[https://www.amerigosportfolio.com/a-crack-in-time---dev-blog/player-attacks-part-3]]></link><comments><![CDATA[https://www.amerigosportfolio.com/a-crack-in-time---dev-blog/player-attacks-part-3#comments]]></comments><pubDate>Sat, 23 Mar 2019 12:19:26 GMT</pubDate><category><![CDATA[Uncategorized]]></category><guid isPermaLink="false">https://www.amerigosportfolio.com/a-crack-in-time---dev-blog/player-attacks-part-3</guid><description><![CDATA[This will be the last part for the attack system for now - I will create the weapon &amp; register the hitbox!I downloaded the weapon pack from Quaternius' Patreon account for use with my player character (his Patreon can be found here).&nbsp;I used the Dagger asset from this pack, and started by creating a new C++ class which inherits from Actor. For now this class is pretty simple, with a method to get the hitbox of the weapon and a constructor. In the constructor I created a StaticMeshCompone [...] ]]></description><content:encoded><![CDATA[<div class="paragraph">This will be the last part for the attack system for now - I will create the weapon &amp; register the hitbox!<br />I downloaded the weapon pack from Quaternius' Patreon account for use with my player character (his Patreon can be found <a href="https://www.patreon.com/quaternius/overview" target="_blank">here</a>).&nbsp;<br />I used the Dagger asset from this pack, and started by creating a new C++ class which inherits from Actor. For now this class is pretty simple, with a method to get the hitbox of the weapon and a constructor. In the constructor I created a StaticMeshComponent and set it as the root component of the Actor, and then I create a BoxComponent to be used for the collision of the attack.&nbsp;</div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="https://www.amerigosportfolio.com/uploads/1/2/2/9/12294026/daggerconstructor_orig.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph">With this class set up, I create a blueprint class which inherited from this one - this way I can set the mesh through blueprint &amp; easily edit properties of the hit box. For the hitbox, I added a new Object Channel for collision filtering for an Attackable object:</div>  <span class='imgPusher' style='float:left;height:0px'></span><span style='display: table;width:auto;position:relative;float:left;max-width:100%;;clear:left;margin-top:0px;*margin-top:0px'><a><img src="https://www.amerigosportfolio.com/uploads/1/2/2/9/12294026/collision-object-channels_2_orig.png" style="margin-top: 10px; margin-bottom: 10px; margin-left: 0px; margin-right: 10px; border-width:0; max-width:100%" alt="Picture" class="galleryImageBorder wsite-image" /></a><span style="display: table-caption; caption-side: bottom; font-size: 90%; margin-top: -10px; margin-bottom: 10px; text-align: center;" class="wsite-caption"></span></span> <div class="paragraph" style="display:block;">I also created two new presets for the attacking - once for the PlayerAttack which overlaps the Attackable objects, and one for the Attackable which blocks all incoming objects. <br />&#8203;For the Dagger blueprint, I created a hitbox that was slightly bigger than the dagger to make the weapon collisions a bit more player-friendly. The end result of the blueprint was this:</div> <hr style="width:100%;clear:both;visibility:hidden;"></hr>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:left"> <a> <img src="https://www.amerigosportfolio.com/uploads/1/2/2/9/12294026/daggerblueprint_1_orig.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph">The next step is to have the dagger spawn in the Player's hand. I opened up my Character class and in the header I added a couple of new fields - a TSubclassOf&lt;Dagger&gt; and the Dagger instance itself. I used this method so that in the blueprint I am able to easily change the Dagger class if I ever need to - in the future I'll make a subclass called Weapon so that I can switch the type of weapon the player has. I also added a getter for the weapon.<br />In the BeginPlay of my character I spawned my Dagger and attached it to the sword socket on the player:<br /></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="https://www.amerigosportfolio.com/uploads/1/2/2/9/12294026/characterdagger_orig.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph">Next I need to edit my character's skeleton to actually add the socket for the weapon. In the skeleton, I added the socket to the MiddleHand_R bone and set the transforms so that the dagger fits correctly into the hand:</div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="https://www.amerigosportfolio.com/uploads/1/2/2/9/12294026/charactersocket_orig.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph">The last class I need to edit is the Player's Attack state so that I can activate the weapon.&nbsp;<br />First, I updated the SetCharacter method in the state to cast the character to a PlayerCharacter object - this way I can retrieve the weapon when required:<br /></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="https://www.amerigosportfolio.com/uploads/1/2/2/9/12294026/attackstatecharacter_orig.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph">Next, I updated the OnEnter method so that I can retrieve the player's weapon &amp; the hitbox, and then register my callback for when the collision box overlaps an object:</div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="https://www.amerigosportfolio.com/uploads/1/2/2/9/12294026/attackonenter_orig.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph">For the next step I had to add the method for the callback. For this method I had to add a couple of new fields to my state:<ul><li>hitActors_ - This is a TArray of all the Actors that have been hit in the current attack. This will be compared against during the overlap so that an Actor isn't accidentally hit twice if they're moving.</li><li>damage_ - This is the amount of damage that the attack will perform.</li></ul>In the callback method, I first iterate through the list of actors and check that the current actor hasn't already been hit. If it hasn't I add the actor to the list and apply point damage to it:<br /></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="https://www.amerigosportfolio.com/uploads/1/2/2/9/12294026/attackcallback_orig.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph">Next I had to update the OnMessageReceived method to perform extra functionality during certain messages:<ul><li>In OnAttackStart, I allow the hitbox to generate overlap events</li><li>In OnAttackEnd, I disable the hitbox's ability to generate overlap events again<br /></li><li>In OnAttackComplete, I empty the list of actors so that the next attack starts fresh, allowing all objects to be hit again.&nbsp;</li></ul></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="https://www.amerigosportfolio.com/uploads/1/2/2/9/12294026/attackmessages_orig.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph">Finally, in the OnExit method if the hitbox exists I de-register my callback from the hitbox.</div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="https://www.amerigosportfolio.com/uploads/1/2/2/9/12294026/attackonexit_orig.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph">Now all I needed to do was test the attack! For testing purposes I created a new Blueprint class for a crate, and attach a box mesh to the object. In the event graph, I added a node for the PointDamage event and used this to damage the crate. The health is decremented, and if it is less than zero the crate is destroyed. I also set the default of the health to 5 so that it can be destroyed in one hit.</div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="https://www.amerigosportfolio.com/uploads/1/2/2/9/12294026/crate_orig.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph">Now, when I run the game you can see the attack!</div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="https://www.amerigosportfolio.com/uploads/1/2/2/9/12294026/attackcrate_orig.gif" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph">With the attack system now in place, the next area of the game I'm going to be looking at is the Stop Time ability! This system will also be split into multiple posts, so stay tuned!</div>]]></content:encoded></item><item><title><![CDATA[Player Attacks Part 2]]></title><link><![CDATA[https://www.amerigosportfolio.com/a-crack-in-time---dev-blog/player-attacks-part-2]]></link><comments><![CDATA[https://www.amerigosportfolio.com/a-crack-in-time---dev-blog/player-attacks-part-2#comments]]></comments><pubDate>Mon, 11 Mar 2019 22:03:43 GMT</pubDate><category><![CDATA[Uncategorized]]></category><guid isPermaLink="false">https://www.amerigosportfolio.com/a-crack-in-time---dev-blog/player-attacks-part-2</guid><description><![CDATA[Now that the animation is all set-up, the next thing I needed to implement was the attack state for the player. For my game, I'm currently going to have a combo system where the player can press the attack button multiple times to chain a melee attack. In the future, I might look at having different melee attacks such as strong attacks and special attacks, but for now I'll focus on the standard melee attacks.First, I needed to add a new state class that the player can enter for attacking. I adde [...] ]]></description><content:encoded><![CDATA[<div class="paragraph">Now that the animation is all set-up, the next thing I needed to implement was the attack state for the player. For my game, I'm currently going to have a combo system where the player can press the attack button multiple times to chain a melee attack. In the future, I might look at having different melee attacks such as strong attacks and special attacks, but for now I'll focus on the standard melee attacks.<br /><br />First, I needed to add a new state class that the player can enter for attacking. I added multiple variables to this class:<ul><li>The animation instance - used to trigger the attack animation montage</li><li>An int32 for the current combo count - this is to keep track of how many attacks the player has completed</li><li>An int32 for the maximum combo count - used to prevent too many attacks</li><li>A bool for whether or not a combo has been chained - this prevents spamming of the attack button</li><li>A bool for whether or not the player is in the "combo area" - this way, the player can only chain attacks between certain frames of the animation</li></ul>I started overriding the OnEnter method from the IState interface - in this method I have reset the variables and told the animation to start the attack montage.<br />Next, I overrode the OnMessageReceived method, which is where the bulk of the logic will be as the state will handle messages from the animation - this method looks like the following:</div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="https://www.amerigosportfolio.com/uploads/1/2/2/9/12294026/attackstatemessages_orig.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph">In the OnAttackStart and OnAttackEnd, I will eventually activate the weapon however for now I have activated &amp; deactivated the combo area. The OnAttackComplete message resets the playNextAttack boolean so that the player can trigger another combo attack. Finally, the OnAnimationComplete message will change the state to the Idle state.<br />Next I have overridden the the OnActionInputReceived method, where I check if the input is the Attack input, and if it is the player can attempt to combo an attack. The method looks like the following:</div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="https://www.amerigosportfolio.com/uploads/1/2/2/9/12294026/attackstateactioninput_orig.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph">Finally, I overrode the OnExit method to stop the attack on the animation instance.<br /><br />I had to create a subclass of the animation instance so I could add my own custom methods for performing the attacks. I added a variable for the animation montage of the attack, and 3 methods - StartAttack, ChangeAttack and StopAttack:<br /></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:left"> <a> <img src="https://www.amerigosportfolio.com/uploads/1/2/2/9/12294026/customanimationinstance_orig.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph">In the ChangeAttack method, I form the section names for the montage &amp; tell the montage to set the next section. The StartAttack method simply starts the montage, and the StopAttack method stops the montage. Once this class was complete I re-parented the animation blueprint of the player to my new class.<br />The last step was to add the state to the PlayerController. Now, the player can attack:<br /></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="https://www.amerigosportfolio.com/uploads/1/2/2/9/12294026/attack_orig.gif" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph">In the next post I will discuss how I implemented the hitbox &amp; the particle effect for the attack.</div>]]></content:encoded></item><item><title><![CDATA[Player Attacks - Part 1]]></title><link><![CDATA[https://www.amerigosportfolio.com/a-crack-in-time---dev-blog/player-attacks-part-1]]></link><comments><![CDATA[https://www.amerigosportfolio.com/a-crack-in-time---dev-blog/player-attacks-part-1#comments]]></comments><pubDate>Mon, 11 Mar 2019 21:17:01 GMT</pubDate><category><![CDATA[Uncategorized]]></category><guid isPermaLink="false">https://www.amerigosportfolio.com/a-crack-in-time---dev-blog/player-attacks-part-1</guid><description><![CDATA[I've decided to split the player attack explanation into multiple parts, as there's quite a lot to go through. This part will mainly explain how the animations are played for the player's attacks &amp; the notifications into the PlayerController.I decided to use an Animation Montage to put together the sword attack combos. For this temporary asset, I only had the 1 attack animation so to create the combo I added the animation multiple times into the montage, reversing the next animation for the  [...] ]]></description><content:encoded><![CDATA[<div class="paragraph">I've decided to split the player attack explanation into multiple parts, as there's quite a lot to go through. This part will mainly explain how the animations are played for the player's attacks &amp; the notifications into the PlayerController.<br /><br />I decided to use an Animation Montage to put together the sword attack combos. For this temporary asset, I only had the 1 attack animation so to create the combo I added the animation multiple times into the montage, reversing the next animation for the follow-up attack. I then trimmed each animation so it flows directly into each other and split each part into sections, and by the end the sections looked like this:</div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="https://www.amerigosportfolio.com/uploads/1/2/2/9/12294026/attackmontage_orig.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph">By default, each section will play an animation and if it is not told to play another section it will play the wind-down animation and end the attack.<br />For the next part of this montage I needed to add the notify events so that the state can be messaged when the attack end, when the animation is complete and when the attack should be activated.<br />For the AttackComplete and AnimationComplete events I used a basic Notify, whereas for the Attack active state I used a NotifyState - this way I can make the attack active with the NotifyBegin and NotifyEnd methods.<br />I created a subclass for the NotifyState which is used to notify the PlayerController about the attack becoming active using a message. Currently, the NotifyState only works with the PlayerController but in the future I might need to refactor this to be more generic. In the end, this class looks like this:&nbsp;<br /></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="https://www.amerigosportfolio.com/uploads/1/2/2/9/12294026/attacknotifystate_orig.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph">I added multiple null checks into the GetPlayerController method to ensure that the PlayerController is valid, and I send the attack start &amp; end message through to the player controller if it is.&nbsp;<br />&#8203;I then added the notifications into the animation montage at key points during each animation, so the final result looked like this:<br /></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="https://www.amerigosportfolio.com/uploads/1/2/2/9/12294026/attacknotifiesmontage_orig.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph">Now with the montage setup I needed to add the montage to the animation blueprint. First, I updated the AnimGraph to play the montage between the default pose like so:</div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="https://www.amerigosportfolio.com/uploads/1/2/2/9/12294026/attackanimgraph_orig.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph">I assigned the slot to be the AttackSlot that I defined, and hooked up the animation to the final animation pose.<br />I then updated the EventGraph for the new animation to allow for sending messages to the player controller after the montage events:<br /></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="https://www.amerigosportfolio.com/uploads/1/2/2/9/12294026/animationblueprintattacknotify_orig.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph">I added three variables to the blueprint - an FName for the Attack completing, an FName for the Animation completing and a PlayerController instance. I added the PlayerController so that I wouldn't have to continuously cast the controller for the notifies.<br />I then implemented the BeginPlay method to obtain the player controller &amp; set it.<br />Finally I added the events for both AnimNotify events which will simply send a message to the player controller.<br /><br />The animation blueprint &amp; the animation are now both ready for the attacks! The next post will discuss the implementation of the Attack state.<br /></div>]]></content:encoded></item><item><title><![CDATA[Character State]]></title><link><![CDATA[https://www.amerigosportfolio.com/a-crack-in-time---dev-blog/character-state]]></link><comments><![CDATA[https://www.amerigosportfolio.com/a-crack-in-time---dev-blog/character-state#comments]]></comments><pubDate>Mon, 04 Mar 2019 20:19:52 GMT</pubDate><category><![CDATA[Uncategorized]]></category><guid isPermaLink="false">https://www.amerigosportfolio.com/a-crack-in-time---dev-blog/character-state</guid><description><![CDATA[So before I jumped into creating the attack logic I decided to do a minor refactor to allow for the PlayerController to control the current state. The idea behind this is that the state will dictate what exactly to do with any input or other messages that it receives from the controller. Initially I'm going to have the following states for the character:Idle/Movement - the state where the player can navigate the map &amp; jump etc.Attack - The state where the player can attack enemies with his s [...] ]]></description><content:encoded><![CDATA[<div class="paragraph">So before I jumped into creating the attack logic I decided to do a minor refactor to allow for the PlayerController to control the current state. The idea behind this is that the state will dictate what exactly to do with any input or other messages that it receives from the controller. Initially I'm going to have the following states for the character:<ul><li>Idle/Movement - the state where the player can navigate the map &amp; jump etc.</li><li>Attack - The state where the player can attack enemies with his sword.</li><li>Interact - Where the player can interact with the environment/NPCs</li><li>Power/Abilities - Certain abilities may use different controls or messages. I'll flesh this out as I develop the abilities.</li></ul> As the game progresses I imagine there'll be more states required to separate character logic, however for now these states should work well.<br /><br />I decided to use an interface for the character state called IState, however I encountered a number of issues while creating the interface. This was mainly due to documentation online being seemingly catered to the Blueprint implementation of the interface.&nbsp;<br /><br />Documentation online showed that interfaces should be implemented via the UFUNCTION macro with the&nbsp; BlueprintNativeEvent or BlueprintImplementableEvent tag. Using this method, in the class that inherits from the interface the method needs to override Method_Implementation() instead of just Method(). Then, to call the method, you can use the static method in the interface and pass in the object you want to call the method on. For example, with an interface callled IState and a method called OnEnter, call IState::Execute_OnEnter(myActor).<br /><br />&nbsp;However, for a pure C++ implementation, you can use standard pure virtual methods to define the interface methods &amp; override them as usual.<br /><br />I first created a new class in Unreal making it a subclass of UInterface. With the interface, all methods are defined in the class prefixed with I, so my state looks like this:<br /></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="https://www.amerigosportfolio.com/uploads/1/2/2/9/12294026/state_orig.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph">So when a state begins, the OnEnter is called and when its complete OnExit is called. When the states are created the PlayerController sets the OnComplete callback and the Character that the state will alter. When the PlayerController receives any input or messages, they are forwarded on to the state. For the OnComplete callback and the Character, I decided to keep those methods pure as interfaces should not contain any logic.<br />For the OnComplete callback, I used Unreal's Dynamic Delegate with 1 parameter so that the state can tell the controller which state to enter next. The delegate looks like this:<br /></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="https://www.amerigosportfolio.com/uploads/1/2/2/9/12294026/delegatedefinition_orig.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph">I then added a new state for the player called USPlayerIdle, which inherits from UObject and IState. For this state, I moved the movement logic in from the PlayerController which looks like this:</div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="https://www.amerigosportfolio.com/uploads/1/2/2/9/12294026/idlestate_orig.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph">In the OnActionInputReceived method, I've added a check for the Attack input binding which will execute the OnComplete callback to start the Attack state. The rest of the state is empty for now.&nbsp;<br /><br />The last change I had to perform was to the PlayerController to take into account the player's state. I've added a new PopulateStateList method which will fill a TMap with implementations of the IState interface, with the key being an FName. I added an InitialiseStates method which then passes through the OnComplete delegate and the character to each state - this method looks like the following:<br /></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="https://www.amerigosportfolio.com/uploads/1/2/2/9/12294026/stateinitialisation_orig.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph">In BeginPlay, I call the two new methods &amp; set the current state to be my new Idle/Movement state. Finally, I altered the input methods to pass the input to the current state as so:</div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="https://www.amerigosportfolio.com/uploads/1/2/2/9/12294026/stateinput_orig.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph">So now its back to where it was before, but cleaner!<br /><br />Next post will be the Attack implementation, which might be split into 2 depending on the length.<br /></div>]]></content:encoded></item><item><title><![CDATA[Changing Character]]></title><link><![CDATA[https://www.amerigosportfolio.com/a-crack-in-time---dev-blog/changing-character]]></link><comments><![CDATA[https://www.amerigosportfolio.com/a-crack-in-time---dev-blog/changing-character#comments]]></comments><pubDate>Tue, 26 Feb 2019 16:44:11 GMT</pubDate><category><![CDATA[Uncategorized]]></category><guid isPermaLink="false">https://www.amerigosportfolio.com/a-crack-in-time---dev-blog/changing-character</guid><description><![CDATA[So I managed to get the character moving around, but now I need to get a character to attack with a sword. To do this, I've had to switch characters - so I'll show how I did that!The model that I used came from a Patreon named Quaternius, he has some great low poly models that you can check out here.First I imported the model into Unreal, drag the model in and in the dialog ensure that you select Import Animations under the animation tab:         Once the process is complete, the model should be [...] ]]></description><content:encoded><![CDATA[<div class="paragraph">So I managed to get the character moving around, but now I need to get a character to attack with a sword. To do this, I've had to switch characters - so I'll show how I did that!<br /><br />The model that I used came from a Patreon named Quaternius, he has some great low poly models that you can check out <a href="https://www.patreon.com/quaternius?fbclid=IwAR1_DIxGXG2iRo2KAdjVkko2Lgw2FgVwp_fWCech6pseBvqTerA9RpNfheY" target="_blank">here</a>.<br /><br />First I imported the model into Unreal, drag the model in and in the dialog ensure that you select Import Animations under the animation tab:<br /></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="https://www.amerigosportfolio.com/uploads/1/2/2/9/12294026/unrealimport_orig.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph">Once the process is complete, the model should be available in Unreal.<br /><br />The next thing I needed to do was to rework the animation blueprint for the new character. I decided to create a new blueprint rather than rework the existing one as it would be simpler to work it that way. However, I did base it on the previous one. For the run animation, I used a BlendSpace between the Idle, Walk &amp; Run animations so that as the player's speed increases, it will change the animation as seen below.</div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="https://www.amerigosportfolio.com/uploads/1/2/2/9/12294026/idle-run-blendspace_1_orig.gif" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph">Next I made the blueprint for the animation - this is essentially a copy of the other animation blueprint but with the new character's animations.&nbsp;<br />Finally, in the character blueprint on the mesh component I changed the skeletal mesh and selected my new animation blueprint as seen below:<br /></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="https://www.amerigosportfolio.com/uploads/1/2/2/9/12294026/playeranimation_1_orig.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph">Now, if I play the game we can see the new character!</div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="https://www.amerigosportfolio.com/uploads/1/2/2/9/12294026/newcharactermove_1_orig.gif" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph">The next target for the project will be an attack system.</div>]]></content:encoded></item><item><title><![CDATA[Character Movement]]></title><link><![CDATA[https://www.amerigosportfolio.com/a-crack-in-time---dev-blog/character-movement]]></link><comments><![CDATA[https://www.amerigosportfolio.com/a-crack-in-time---dev-blog/character-movement#comments]]></comments><pubDate>Mon, 25 Feb 2019 20:24:15 GMT</pubDate><category><![CDATA[Uncategorized]]></category><guid isPermaLink="false">https://www.amerigosportfolio.com/a-crack-in-time---dev-blog/character-movement</guid><description><![CDATA[Fresh start on a new project - it's always exciting! I'm going to use this blog post to detail how I set up the project &amp; getting the character to move in the way that I want.I created the project using the Unreal template for a top down game with C++. This gave me a bit of a head-start on the project, however the movement isn't how I planned it - the demo works by clicking where you want the player to move! I'll show how I switched it to keyboard &amp; GamePad movement.First, I'll need to a [...] ]]></description><content:encoded><![CDATA[<div class="paragraph">Fresh start on a new project - it's always exciting! I'm going to use this blog post to detail how I set up the project &amp; getting the character to move in the way that I want.<br /><br />I created the project using the Unreal template for a top down game with C++. This gave me a bit of a head-start on the project, however the movement isn't how I planned it - the demo works by clicking where you want the player to move! I'll show how I switched it to keyboard &amp; GamePad movement.<br /><br />First, I'll need to add the input bindings for the movement. Go to Settings -&gt; Project Settings, then scroll down the left tab to Input under the Engine heading. You should see something like this:</div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="https://www.amerigosportfolio.com/uploads/1/2/2/9/12294026/projectsettings_orig.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph">In here you can add the bindings for any input in the game. Action Mappings are used for input without a scaling value, such as a button press on a keypad, whereas Axis Mapping will provide you with a scaling value between 0 and 1 that can be used to scale the movement speed for example. I've added a new Action Mapping first for a Jump method which is triggered by the space bar or with the bottom face button on a GamePad - on an Xbox controller this translates to the A button.&nbsp;</div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="https://www.amerigosportfolio.com/uploads/1/2/2/9/12294026/actionsettings_orig.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph">Next I added some Axis Mappings - these are used for character movement as I want my character to move slower if the analog stick is only slightly pressed. There were already some keyboard bindings in here, so I added a couple of bindings for the thumbsticks like so:</div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="https://www.amerigosportfolio.com/uploads/1/2/2/9/12294026/axissettings_orig.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph">Now onto the fun bit - the code! The standard PlayerController that comes with the test project has a lot of redundant code that I didn't really need for my game, so I created a new one. It's quite a simple class, all it does is bind the input for the mappings defined above. Luckily the Pawn and Character classes have the functionality that I need, so when MoveForward/MoveRight are called I call GetPawn()-&gt;AddMovementInput and pass in the direction and the scale value. For the Jump method, I just need to call Jump on the character being controlled - the final class looks like this:<br /></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="https://www.amerigosportfolio.com/uploads/1/2/2/9/12294026/controllercode_orig.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph">Now there's some basic movement working! However there were still some tweaks that I needed to do as the movement didn't feel right. First, the character looked like he was sliding around - to fix this, in the custom character class I set the ground friction to 300. This seemed to do the trick, however it may need tweaking in the future.<br /><br />Next, I wanted a bit of movement in the air so that if the player tries to change direction while jumping it'll move slightly - this was another easy fix, on the character I set AirControl to 1.<br /><br />Finally, the camera angle wasn't what I was after, I wanted it to be rotated down a little bit more. This was a bit trickier than it should have been, as something was changing my rotation of the spring arm component back to its default. This was due to the Blueprint of the character trying to set it back to the default - after setting the change in the blueprint the issue seemed to be resolved!<br /><br />The end result looks like this:<br /></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="https://www.amerigosportfolio.com/uploads/1/2/2/9/12294026/charactermove_2_orig.gif" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph">In the next post, I'll explain how I switched the default player model into a custom one.</div>]]></content:encoded></item><item><title><![CDATA[A Crack in Time (Working Title) - Intro]]></title><link><![CDATA[https://www.amerigosportfolio.com/a-crack-in-time---dev-blog/a-crack-in-time-working-title-intro]]></link><comments><![CDATA[https://www.amerigosportfolio.com/a-crack-in-time---dev-blog/a-crack-in-time-working-title-intro#comments]]></comments><pubDate>Mon, 25 Feb 2019 20:21:18 GMT</pubDate><category><![CDATA[Uncategorized]]></category><guid isPermaLink="false">https://www.amerigosportfolio.com/a-crack-in-time---dev-blog/a-crack-in-time-working-title-intro</guid><description><![CDATA[&#8203;This game is my current personal project that I am working on. It is a top-down action game where the player must save the world through multiple time periods, and the player can use time-related powers such as stopping time in a small area around themselves.There are going to be 5 different periods that the player will have to play through, which uses the same world map but with variations based on the time period - for example, in one time period there may be a small town but in the nex [...] ]]></description><content:encoded><![CDATA[<div class="paragraph">&#8203;<span style="color:rgb(163, 162, 162)">This game is my current personal project that I am working on. It is a top-down action game where the player must save the world through multiple time periods, and the player can use time-related powers such as stopping time in a small area around themselves.</span><br /><span style="color:rgb(163, 162, 162)">There are going to be 5 different periods that the player will have to play through, which uses the same world map but with variations based on the time period - for example, in one time period there may be a small town but in the next time period this town has turned into a city.&nbsp;</span><br /><br /><span style="color:rgb(163, 162, 162)">The game is being developed using Unreal Engine 4.21, and this page will be updated with my progress with blog posts that state how I achieved certain functionality.</span><br /><br /><span style="color:rgb(163, 162, 162)">The milestone I am working on at the moment is to have the character controls implemented. This includes:</span><ul style="color:rgb(163, 162, 162)"><li>Character movement &amp; jumping</li><li>Attacking with a sword</li><li>Stop Time ability.</li></ul> <span style="color:rgb(163, 162, 162)">Once this milestone is complete I will be working towards defining &amp; implementing more abilities that the player can use before implementing enemy logic.</span></div>]]></content:encoded></item></channel></rss>