Increasing the projectile's speed

Now that we have given the player character a new gameplay option to navigate the world, our focus will be back to the shooting mechanics. Right now, the shots fired from the gun on the controller are spheres that slowly arc through the air. We want to better approximate the fast-moving bullets that we are used to in traditional shooters.

To change the properties of Projectile, we need to open the Blueprint called FirstPersonProjectile, which is located in the same Blueprints folder as FirstPersonCharacter. Once opened, look at the Components panel and click on Projectile. This is a projectile movement Component that has been added onto our sphere mesh and collider to define how the sphere will travel once it is created in the world.

In the Details panel, you will see that Projectile is made up of a long series of values that can be modified relative to movement. We are interested in only a couple of these at this time:

First, find the Initial Speed and Max Speed fields, which are currently set to 3000. Initial Speed determines how fast the projectile travels when it is first created at the tip of our gun, and Max Speed determines how fast it can reach if an additional force is applied to it after creation. If we had a rocket, we might wish to apply acceleration to the rocket after it is launched to signify the thruster engaging. However, since we are representing a bullet coming from a gun, it makes more sense to make its initial speed the fastest that the bullet will ever travel at. Adjust both Initial Speed and Max Speed to twice their original value: 6000.

Additionally, you might have noticed that the current projectile bounces off walls and objects as if it were a rubber ball. However, we want to mimic a harder and more forcefully impacting projectile. To remove the bouncing, look for the Projectile Bounces section in the Details panel and uncheck the box next to Should Bounce. The other values dictate the way in which the projectile bounces only if Should Bounce is checked, so there is no need to adjust them. One last change to make in Event Graph is to connect the False pin of the Branch node to the DestroyActor Function so that the projectile is always Destroyed when it collides with anything.

Now, compile, save, and click on Play. You will find that shooting the gun results in a much further-reaching projectile, which behaves more like a bullet, and that the projectile does not bounce off the walls anymore.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset