i have created an asteroid field blueprint ,who are (each time the game launch)generated randomly (size,number) and who are fully destructible,now i want to add to this field the movement factor random(having each asteroid moving in the space)
a little like this for give an example - YouTube (6.00 to end)
Sorry for the delay!
Ok I found a pretty simple way for you to do this, here is a video to show the result.
First of all, I used an Orthographic camera and did not give any depth movement. But you could easily use a perspective view and add movement to the other axis (in my case the X axis) that I did not use if you plan on having a 3D navigation like in the video you showed.
To begin, add the components of your asteroids inside the components tab. You need a Rotation Movement Component, a Projectile Movement Component, a Box Component and your Static Mesh or whatever you are using to represent your Asteroid. Set the Box Component as your Root and give it a collision (BlockAll probably works best here).
Also, change these settings in the Details tab of your Projectile Movement Component
With that set up, go to you Blueprint’s Construction script and create these 2 variables; Vector variable called Direction and a Rotation variable called… Rotation?
Afterwards, set the Direction and Rotation variables as shown below (Ignore the set Actor Relative 3D Scale and Set Actor Relative Rotation as you already have a Blueprint that handles that right?). As mentioned above, you can give values to all 3 axis of the Vector variable if you want 3D navigation. Also, for the same purposes, you would add values to the Pitch and Yaw of your Rotation Variable as needed. In my case I did not need them as I made a simple 2D example.
Ok, now to the Event Graph! Follow the Image below. Nothing special about it, it’s pretty straight forward. Get your Rotation Movement and pull a Set Rotation Rate from it. Get your Projectile Movement and pull a Set Velocity in Local Space form it. Ignore the text as we already covered that in our Components Tab.
And that’s it, you should have some happy asteroids moving around and colliding and bouncing around! Tweak the variables to your need! If you don’t want your Asteroid to wander off into space, you can place invisible walls outside of the player view to make the Asteroids bounce back into the game.
Hopefully this helps you out, have a nice day!