Building the Asteroids (Part 1)

Okay, so now we’re going to continue on with the asteroid. And the next thing we’re going to do is build out our Construction Script, we’re actually going to tell it to have a rotation rate and velocity and forward vector and then tell it to select that static mesh and then material. Two pretty straightforward. Nothing too complex. So let’s get started. So we’re going to set our rotation rate. We’re going to grab the rotating movement and do sup rotation rate and add it to the Construction Script script. I’m gonna add a random rotator. Make sure you did not check roll. And then we’re gonna move on to setting the velocity for the projectile movement. Drag that in LA City. And this time we’re gonna do a random float in range, I’m gonna do either negative one or positive one. And let’s duplicate that one more time. And we’re going to do a make vector like we’ve done several times before. connect those up and then bring that into the velocity. And then we’re going to do a forward vector and pop that in as well. Then we’re going to bring in select Static Mesh, and select asteroid material. And if everything compiles successfully, we should have asteroids showing up now. Let’s hit play. Okay, before we go ahead hit play, we’re going to go to our editor Level Blueprint. And if you recall, we set up in our Event Graph a timer up here, we’re going to want to call that spawn asteroid function. So add that to the the false because he is not dead. And then we’re going to actually continue on here and we’re going to build out the on death event. So, get all actors from all actors. Class, VP asteroid, got a copy of that, and then pass the VP asteroid and then when you get hit by It you’re going to spawn and let’s do a transform location. Get transform location, and we’re going to do spawn actor. From class, we’re going to select our VP player ship pawn, because we want to spawn a new player here and add the spawn transform. And then we’re going to make sure we possess the pawn. Let’s do return value possess. Why can I not Oh, I don’t have to do Player Controller first, then. Excellent. And then when the cast to BP Player Controller and we’re going to determine the lives, deadlines and Let’s make sure we do get Player Controller here. And I didn’t make a mistake, I believe No, actually we are good there. So we did the Player Controller. Okay, we’re going to do less than equal to, and we’re going to do a branch that up. And on cast. We’re gonna do true. Cast you player, ship, pawn, Get Player pawn. And on fail, we’re going to do Reese up we haven’t built that function yet. So let’s go back over here. Let’s create a function called response Custom Event. Sorry, not a function response. And we’re going to tap in from right here. Awesome. Save, Compile. Okay, clean that up a little and then we’re Going to do respond if it’s false. Destroy the actor. Great widget. And we’re going to put that game over screen Add to Viewport and this will tell will set is dead officially dead. Okay, great. And that should be it there. Let’s make sure we have that timer. Okay, so we need to actually do spawn, we need to create a new function here and do spawn asteroid. And this is gonna have, essentially our random transform for spawn asteroids. What’s gonna happen when you mess with the different balls. So first thing we’re going to start with is the spawn asteroid and that’s going to go to a branch. We’re just going to duplicate this four times for four different branches here. So false goes to their false branch and false branch. We’re gonna do random integer, maximum maximum for because of course it is the walls that we’re targeting. And we’re going to do equals integer. So one equals zero. Oops, sorry. let’s reverse that. Next one, one. Two, three. So we start from 0123. So that’s for Matt. Okay. And now what do we do with the true Okay, so this is gonna be a lot of craziness so bear with me. So we’re gonna do spawn actor from class just like usual. I’m gonna do BP asteroid. We’re going to duplicate this four times. So let’s bring this up here, duplicate four times. And let’s make sure our trues are linked. Excellent. Now if you notice, we actually are missing in quite a few things here, so we don’t have our spawn transform set. So we need to do that. And we need to call our outer walls. So let’s go back over here and let’s first select BP wall and create a reference to BP wall BP wall to create a referenced BP wall to create a reference to BP wall three and then create reference for BP wall four. Okay, and let’s make sure that these are split separately from each other. We’re gonna get we’re world location from default scene route. duplicate this okay. Then we’re going to break the vector like usual. Break factor. Excellent. We’re going to do make vector. But we’re not going to connect to the x value, we’re just going to connect to y. So there we go. duplicate this again. Excellent. Next, we’re going to make transform, just like normal. And we’re going to do location, rotation the way it is. So let’s break these out. And we’re going to line these up as close as possible. Pile save. Let’s see if we have that set. I might need to make sure that these walls are set the correct way. I believe they are. Oh, I did make a mistake. We actually need these two walls to be different values. They need to be the x and the z value. And then we’re gonna go over here we’re gonna do a random flow. float in range, multiply, float by float, make it one absolute float. Okay. Not the absolute float there. And I have this in reverse, so let’s fix that. So negative one. So random float in range. So we’re gonna bring this to our y value, y, and then our x value, x value and we’re going to connect Make sure here to connect this value. So this x and that should be it actually had these two in reverse. So this one needs to go up here and this one go over here. And that should solve that issue. Now if we hit play, you should start seeing some asteroids coming in. You notice if you hit the asteroid, it does kill you and you’re live Connor goes down by two, or one sorry. So if I hit this guy, I missed them. Try to hit an asteroid. There we go down one. And if I shoot him spawn these little tiny asteroids. And we also have these guys to pick up. But I noticed the pickup animation or the pickup is not working as expected. So let’s take a look at that coin, we might not have the collision set properly. So let’s look at the coin here BP coin, static mesh, simulate generation block all dynamic. So I think we have that wrong. So if I’m looking at it, we want to do custom. And we want to do collision enabled but we want to do world dynamic. That’s correct. Ignore ignore, and that should be good. So I think that will resolve that issue. And you know what, I bet I never built the clock double logic. Yep, that was it guys. So BP Player Controller we’re gonna do get player solar actually don’t need that. Why am I adding that we want to do cast dp player ship pawn Connect object and then we’re going to do destroy actor and of course we can add more functionality to this if we like if we want it to you know give us more points but for now we’re just gonna have it just destroy actor Okay, oh, I’m having it destroy myself. I did not mean to do that. Apologies. Okay, we got a coin right there. Excellent. We got it. And now you could actually have those coins do power ups. We could add more to the ship for example we could add to spawn points and have it do dual fire if we liked. There’s unlimited possibilities here that we could add but for now we just want to disappear So with that, we’re going to move on to the UFO.