Now that the player will successfully travel from point to point within the level and will no longer skip any steps before reaching the end, I now need to rotate the player camera since presently if I make the "Simple Move to Location" node move the players location left or right the player camera does not turn to match this and the player just watches as their character is forcefully pushed to the side while they start at a wall. This isn't good sine if the enemy character was to attack the player during this movement the player would not see the attack animation or have chance to respond and shoot at the enemy character as they don't have any control over the player characters movement or orientation, instead I the developer has that control.
As with making the player character move from Target Point #2 to Target Point #3 I could just use the "Set Actor Rotation" node to snap the player viewpoint from what it was to the new direction where I wish their attention to be, however, just like the "Set Actor Location" node this is far too sudden for the player to have an enjoyable experience but unlike that previous solution for player movement there isn't an alternative node such as "Simple Rotate" that I can plug the new direction rotation into and have it smoothly transition between the two rotational values. The change this sudden snap from Rotation #1 to Rotation #2 and make it smooth I need to create a string of code where the engine will find the differences between the two rotational data points then linearly adjust between them. For this linear transition I am going to use a "Timeline" which is a function of Unreal Engine that will allow variables to change over a set period of time.
To start with timelines you need to create a "add Timeline" node then open it up (double click) and create a new "Track" in relation to the variable type you are changing (float or vector or event), which in my case here is a float track as that will give me the linear difference I am searching for between the two rotational data points I have. The job isn't finished yet, inside the float track I created two Key frames which store information at two points of the track (Start and End) and then told the engine to make a curve joining these two points so that the transition between frames is exponential. The secondary key frame will decide how long this transition between rotation #1 and rotation #2 (must be less then or equal to the "Track Length" value) and the number entered into key frame #2's "Value" section will decide the number of degrees that the rotational data is increased by. One final step is once the rotation is done and the timeline track has ended the timeline node will reset the player camera's rotation to the 1st key frame but will not continue onto the other key frames, this is a nuisance for me as I was using the timeline to edit a variable that I wish to keep the changes of and so the fix is to set the control rotation this time as the newest changed version of the rotation variable but once the track has end so this will be plugged into the the "Finished" pin of the Timeline's node in the Event Graph.
Comments
Post a Comment