

Set this actor to call Tick() every frame. You are making CollisionComponent a RootComponent since the simulation will drive it.įPSProjectile.cpp should now look like the following: Set the root component to be the collision component. Use a sphere as a simple collision representation.ĬollisionComponent = CreateDefaultSubobject(TEXT("SphereComponent")) ĬollisionComponent->InitSphereRadius(15.0f) RootComponent = CreateDefaultSubobject(TEXT("ProjectileSceneComponent")) Locate the FPSProjectile class CPP file in the Solution Explorer and open FPSProjectile.cpp.Īdd the following code to the AFPSProjectile constructor (after PrimaryActorTick.bcanEverTick) in FPSProjectile.cpp: Virtual void Tick( float DeltaTime ) override Called when the game starts or when spawned Sets default values for this actor's properties All Rights Reserved.Ĭlass FPSPROJECT_API AFPSProjectile : public AActor

UPROPERTY(VisibleDefaultsOnly, Category = Projectile)įPSProjectile.h should now look like the following: Locate the FPSProjectile class header in the Solution Explorer and open FPSProjectile.h.Īdd a reference to a USphereComponent in the FPSProjectile interface. Name the new class "FPSProjectile," then click Create Class. Scroll down, select Actor as the parent class, and click Next. Your input settings should now look like the following: In the dropdown menu, select Left Mouse Button from the Mouse dropdown list. Type "Fire" into the text field that appears, then click the arrow to the left of the text box to expand the action binding options.

Under Bindings, click the plus sign next to Action Mappings.Ĭlick the arrow to the left of Action Mappings. Under the Engine heading on the left side of the Project Settings tab, click Input. In the Edit menu, click Project Settings. During this step, you are going to add input and create a new code class for our projectile. You are going to program a simple grenade-like projectile to shoot from the center of the screen and fly until it collides with the world. Now that you have set up your character, it's time to implement a projectile weapon. Get Your Projectiles to Interact with the Worldģ.3 - Setting Up Projectile Collision and Lifetimeģ.4 - Getting Projectiles to Interact with the World The purpose of this section is to show you how to implement projectiles for your First Person Shooter game.īy the end of this section of the tutorial, you'll be able to: This is what you'll see at the end of this section.
