[flow_default] Transcription: 003 Calculating thrust and forward velocity.json
Browse files
transcriptions/003 Calculating thrust and forward velocity.json
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"audio_file": "003 Calculating thrust and forward velocity.wav",
|
| 3 |
+
"text": "Now the next thing for me to do is go to the event graph and I'm going to start setting up some variables. So I'm going to add, first one is going to be thrust, not what I'm looking for, I'm going to change that to a float. Now once I change this value to a float, excuse me, Every variable I add afterwards is also gonna be a float, which is nice because I have a few floats to add. Also gonna add max thrust. And we're gonna add gravity threshold. Now, it's really important to set the default value of max thrust and gravity threshold. These are constants that we're going to be using in our actual blueprint, whereas thrust is a variable that we're going to be changing depending on, well, how much thrust we are actually generating at the moment. So it can stay as zero as you can see over here. If I go to default value, oh, I need to compile the blueprint first. If I go to default value, it's zero here, that's fine. This one we're gonna set at 1000, so 5000 actually. And 1000. All right, so now that we have those set, we're also gonna create two vector variables. So, oh my gosh. I'm just gonna delete that actually. Cooperate with me, Unreal, come on. This one's going to be a vector. And we're also going to create, ohell. Cool. All right, so we've got our velocity. We've got our thresholds. We have our thrust. We're going somewhere here. OK, so the first thing we need to do is bring in those key bindings that we created earlier. Type in binding. What was it? Move up. These are access events. We had move right. What was it? Move y. We're also going to have Rust and Roll. All right. Now that we have all of our axes, we can scroll these up here. Give them a bit more space. We're going to need it. And the most difficult is probably going to be thrust. So I'm going to move that up here. Now we can go ahead and compile. Now I'm going to go back to the viewport. I'm going to click on my mesh mesh and it's really important that we hit simulate physics. Turn the angular damping a bit up. I think 01 should do. In fact, actually let's do 1.00. Awesome. Now let's go back to the event graph and start wiring up our thrust vector. Actually, before that, let's make sure that we have all our default set. Where's event begin play? Bring it up here. Awesome. Now let's start by dragging out set. We're going to set the initial thrust. And we're going to set it just as the max thrust. So I'm going to drag it out here. Max thrust, divide by 2. Basically, we're going to start at half of our maximum velocity, or maximum thrust, I should say. We'll just do 2. Awesome. And we're going to comment. See, and we're going to say, uh, thrust. Good stuff. Oh, we don't know that. It's taken care of. And now let's get started on the thrust. Now what we're going to do is we're actually going to pull out a sequence node. So what a sequence node does is it does one action, and then it does the other one. You could actually line them up all through event. Exact, excuse me, connections, but this is just a more convenient way, especially if you have two very different actions. So we're gonna line, we're gonna pull that there. Now, the next thing we're gonna do is actually use those scale values that we put in our key bindings, the access value, to determine whether or not the person or the player or you is actually playing at the given moment. So it's important to note that the input access thrust event is happening at all times. The difference is that when you're holding down the key, like W in this case, it's going to be changed from its default value, 0, to its active value, 1, or negative 1, depending on your binding. So in this case, if I actually just pull up a print node, and I pull this right here, actually, for the second demonstration, let me show you, I can pull this directly in here. And I play. Oh my gosh, we need to pull this need to go to World Settings. Create our game mode, BP Flying Game Mode. Default Pond needs to be BP Flying Pond. All right, save. Play. Hello. Now look at what's going on here. In fact, actually, let me illustrate this a bit clear. So instead of printing in string, we're actually, oh, I put that, this is Alt to clears pins. That's going to become very important. All right, now you can see this right here. This is actually a conversion node. It's converting from a float here to a string. It does this automatically. So obviously you can't print a number unless you convert it to a string that represents that number. Now we compile and go back. Now we'll hit play. Now we can tap the button to you want to go forward or create thrust and when you want to go backward or remove thrust. So I'm going to get rid of this string, this print string, and I'm going to pull out from this axis value a nearly equal node. Now what this node is going to do is say, if it's not zero, we are going to do something. And I'm actually going to need to use a branch as well. Because this is going to return a Boolean. And I need that Boolean to actually tell me which part of the code or the blueprint I should execute. So I'm going to put the return value in there. Erotonic could be a bit higher. It doesn't really matter at this point because that's fine. At the end of the day, it's only going to be 0, 1, or negative 1. And we're going to need a knot here as well. I know how to make this easy context menus, baby All right, so if it's zero this is gonna be true Which means the not's gonna be false Meaning that whenever it's zero this is gonna false. There we go. Okay guys, now that we've set up this gate that only allows the exact execution through this branch when the input is either one or negative one or we're either pushing forward or backward, W or S, what do we want to do? Well, we want to add to the thrust, but we don't just want to go from our initial thrust to our maximum thrust immediately. Imagine if you went from zero to 100 in an instant. That's not how actual objects work. So we're gonna use two functions that are very often used in Unreal, LERP and F-interp2 to make this happen. So let me pull them in. LERP and F-interp2. Now both of these interpolations essentially are different ways to move from one value to another value gradually. LERP does this linearly. Whereas F in TURP does it even more gradually. So as you approach the value or the target that you're trying to get to, it's going to get slower and slower and slower. This will give us a realistic feeling acceleration inside our airplane. Now to wire this up, the first thing that we're going to need to do is go from max thrust. Why do I keep doing that? When I can just do this, get max thrust. This is going to go into the B of our LURP. And now the A is just going to be zero. We're just starting at zero, and then we're going to our max thrust, right? Now our alpha is going to be the value from our thrust. It's going to be the increment at which we're moving along the zero to, sorry, the A zero to B max thrust interpolation. Now here's the thing. You can't have a negative there because if you did you'd start going backwards which is not exactly what we want. So what I'm going to do is I'm going to grab this axis value over here. Now I'm going to do a plus and divide. Now why am I doing this? Well, simply, I am converting out of 1 there. And now I'm going to add a 2 here. That's a 20. That would not be good. I'm converting from a scale between negative 1 and 1 to a scale between one or zero and one. Just some simple equations for you. I'm going to plug that into the alpha. Now, for this, I'm also going to need the delta time. So the change in time. Let me get delta. There we go. So boom, boom. We're going to add our thrust, right? Because we're trying to go between our current thrust. So I'm going to make sure that that's... I don't know if I trust that. There we go. Current. Our current thrust, right? To the target thrust, which is our max thrust, which after we've lerped it, of course. Now, we're also going to add the interp speed. Let's do 0.25. That should be good. And then finally, what are we going to do with this value? Well, we are going to set the thrust that you have right now, to the max thrust gradually in a realistic manner. Okay, so now what do we need to do? Well, thrust and velocity aren't the same thing. Thrust is just your propulsion forward, whereas your velocity is how fast you're actually going in any given direction. So after we've calculated the thrust, we now need to calculate, using some physics calculations, what our forward velocity is. That's why we have this sequence pin, because we can pull off this then one, right? And we're going to do set for, set for velocity, Boom. Now, the first thing we're going to have to do is we have to know what the current forward velocity is. So grab forward velocity. Oh, excuse me. We can get the current actors for velocity. Get actor forward vector, right? And then we're going to multiply this by thrust. Now it's actually going to require us to do... This is definitely better. Now, let's apply. Now as you can see, this is a float and this is a vector. And this is actually doing a linear algebra calculation on this vector to give us the new forward velocity vector, which I can pull through there. Set, boom. There we go. Now we have calculated the thrust. And with the thrust, we have now calculated the forward velocity at any given moment. Awesome. Now I'm just going to select this, hit C to comment. And we're going to say calculating thrust and forward velocity. Awesome.",
|
| 4 |
+
"language": "en",
|
| 5 |
+
"confidence": null,
|
| 6 |
+
"duration": 1114.58
|
| 7 |
+
}
|