You are on page 1of 23

Hello there, I am going to teach you how to create a homing missile projectile that will attack

and hit certainly the targets that you designate as enemies or as destructible targetable objects.

Before proceeding onto the tutorial, it is important to let you know that this will work
certainly on version 4.7. Therefore, this method has not been tested in older versions,
meaning it is at your own risk that you experiment this on older versions. You might wind
up with different or even unwanted results. You have been warned.

1. To start this tutorial off, it is imperative that you create a new project using the First
Person Template mode in the project browser. Name it and save it whatever and
wherever you want, I am naming my project RocketProject.

2. Now that you have created a new project and saved it, proceed onto the content
browser and select the blueprints folder. You will see a blueprint named
FirstPersonProjectile. Right click and create a duplicate of that blueprint and rename it
RocketProjectile.

3. Open the newly created blueprint and youll see this:

SELECT ALL BLUEPRINTS AND DELETE EVERYTHING. We wont need any of this

4. Now that we deleted the entire node network, switch to the viewport mode of the
projectile and select it in the component panel. We will now proceed to modify some
values of the projectile.

5. In the details panel, we will modify the projectile gravity scale value to 0 so as the
projectile is not affected by gravity. Change the value of initial speed to 2000.0 so as
when fired, the projectile will start moving slow and gain speed over time. You can leave
bounce on or off as well, since the projectile will be exploding anyways.

6. Now click on the add components button, and search for RadialForce. Click on it and you
should have this on your screen

7. Rename the RadialForce component into ExplosionForce:

8. Now with ExplosionForce selected, proceed to the details tab and modify the values of
Radius and Impulse Strength to 300.0 and 500000.0 respectively. Compile and save the
blueprint.

9. Switch to the event graph, and we will now add explosion to the projectile. Start by
selecting the collision component in the component tab.

10. In the detail panel, add a node called OnComponentHit. A new node with the same name
should appear. Drag from the white arrow to add the DoOnce executable action. You
should have something like this:

11. Select ExplosionForce from the variable tab, drag and drop it to the event graph

12. Drag from the endpoint of the ExplosionForce and add the FireImpulse action. Proceed to
connect it with the DoOnce node like so:

13. From the ExplosionForce node, drag once again from the endpoint and attach a
GetWorldLocation node. Then drag from the FireImpulse endpoint and add a
SpawnEmitterLocation (This is the particle effect that will have the projectile when fired).
Attach the GetWorldLocation node to the location point of the SpawnEmitterLocation. It
should look like this:

14. Now from the SpawnEmitterLocation, there is a blue point with a drop box menu where it
says Emitter Template. Proceed to select the Explosion effect like so:

15. From the endpoint of the SpawnEmitter, add the action DestroyActor since we dont want
the projectile to remain after the explosion or impact. If for some reason, you cant get
DestroyActor on the available actions, uncheck Content Sensitive from the search box.

16. Select the entire blueprint collection so far, right click and type: add comment to
selection and add this comment when prompted: Explosion on Contact like so:

17. Compile and save the blueprint so far. Exit the event graph and into the main interface. Go
to the content Browser and find the First Person Character blueprint. Open its event graph.

18. Scroll over to the SpawnActorFirstPersonProjectile node. Under class, make sure to
change the FirstPersonProjectile to our newly created RocketProjectile. Make sure to
compile and save it afterwards. Exit the event graph.

19. Now we play test our game and see if it spawns our blueprint projectile instead of the
default one when fired. Make sure you can send the boxes flying when hit and the
explosion effect plays when the projectiles impact on any surface. If any of those, or both

do not happen, STOP AT THIS POINT and review the steps again up to this point. Make
sure it works before proceeding to the next part.
20. Open once again the RocketProjectile blueprint and go into the event graph, we are going
to add a CustomEvent node. Rename the node as Homing Missile.

21. Select the Homing Missile node. Under Inputs, we will add a new input called TargetToHit.
We will change that to static mesh actor. From the blue endpoint arrow of the node, drag
it and add the function IsValid.

22. From the white arrow endpoint of the Homing Missile node, drag it and add the action
Branch. From there, connect the values (red arrow) of the IsValid function to the
condition Arrow like so:

23. From the variable tab, drag the Projectile to the event graph, similarly like we did on step
11 with ExplosionForce, but this time we will do it with Projectile.

24. Drag the arrow endpoint and add the action Set Homing Target Component.

25. Go back to the Homing Missile, drag from the blue arrow endpoint and add the node Get
Static Mesh Component. Draw from the Branch TRUE (NOT FALSE) white arrow endpoint
and connect to the SET node. Connect the Static mesh component endpoint to the
Homing Target Component begin point like so:

26. We will now proceed to set a Boolean confirming that the projectile is a Homing
Projectile. Drag from the projectile node once again and add the Boolean
SetIsHomingProjectile. Check on Is Homing Projectile and connect both SETs like so:

27. Afterwards, we drag from the projectile node once again, and add the node
SetHomingAccelerationMagnitude. From there, change the value of the homing
acceleration Magnitude value to 25000. This is a high number, but it is high so it can
actually track accurate enough the targets. Then connect SetIsHomingProjectile to
SetHomingAccelerationMagnitude like so:

28. Proceed and group the newly created node network and add the following commentary
Set Homing Missile (like in step16). Compile and save.

29. Go back once again to the FirstPersonCharacter blueprint outside in the content browser
and we will set the target to any object in the level for now (since the level is empty). For
that, right click and add RightMouseButton event in the event graph.

30. Drag from the pressed arrow and add the LineTraceForObjects

31. We now need to determine what kind of object will our homing missile can hit. It is
important to know that this step is crucial for this whole thing to work. It can be actors,
meshes, cameras, you name it. For now we will add it so it hits physic objects and this is
how we proceed on this. Under variables, we will create a new variable and we will name
it ObjectsToTarget.

32. Afterwards, go into the details tab and set the variable type to EObjectTypeQuery. Add an
array. Then, set the value so it only targets PhysicsBody.

Drag the ObjectToTarget variable into the event graph, set it as a GET variable and
connect it to object types in the LineTraceForObjects node.

33. Now drag the FirstPersonCamera from the Component tab and into the event graph.
Then drag from the endpoint to add the GetWorldLocation node and connect it to the
start begin point of the LineTraceForObjects node. Drag once again from the endpoint of

FirstPersonCamera and add GetForwardVector (as in the projectile will follow a vector
when it has chosen a target). In order for the vector to work, you need to multiply it with
a Float, so add a Float* (that means multiplier float) and change the value to 5000.0 like
so:

34. Drag from the endpoint of the Float* to add the Vector+Vector node. Now, reconnect
both Begin points to the Float*, and then drag the superior begin point and connect it to
the return value endpoint of the GetWorldLocation. Afterwards, connect the endpoint of
the Vector+Vector node into the end begin point of the LineTraceForObjects like so:

35. Going forward, drag from the Out Hit endpoint and proceed to create a BreakHitResult
node. Then drag from the return value and place another Branch.

36. Drag from the True endpoint of the Branch node and place CastToStaticMeshActor node.
From this new node, drag from the object begin point and connect it to the Hit Actor
endpoint of the BreakHitResult.

37. Create a new variable called HomingTarget, set it as a static mesh actor, but do not add
an array like we did on step 32. Then Drag it as a GET variable to the event graph.

38. Drag from homing target and add an IsValid node (the one with the ? in it). Then drag
from CastStaticMeshActor endpoint to the Exec begin point of the IsValid node

39. Drag once again from the HomingTarget node and add the SetRenderCustomDepth node
(This is going to be the outline of the object we are going to target). Then drag from the
IsNotValid endpoint to add a SetHomingTarget node, then join the As Static Mesh Actor
from the CastToStaticMeshActor node all the way to the SetHomingTargets Homing
target begin point and finally connect both IsValid endpoint to the
SetRenderCustomDepth begin point like so:

40. Drag from the blue endpoint of the SetHomingTarget and add another
SetRenderCustomDepth. Check on the value of the node and connect the begin point of

the SetRenderCustomDepth to SetHomingTarget and then from SetHomingTarget begin


point to the endpoint of the other SetRenderCustomDepth. Then save and compile. Next
part we need to backtrack a bit.

41. Back on step 36, we dragged from the Branch TRUE to establish the behavior of the
homing targeting when a target was a positive, but what about when there is no target
and there is walls only or the floor. Well now we are going to focus back from the false
endpoint onward to set this aforementioned behavior. Drag from Branch FALSE and add
an IsValid node. Then, from the HomingTarget node, drag to the input object begin point
of the IsValid node.

42. Drag from the HomingTarget node once again and add another SetRenderCustomDepth
node. Check the value box again and connect the main begin point to the IsValid
endpoint.

43. Ok, now we have a really cluttered blueprint, go ahead and select the entire thing. Add
the following comment to the selection: Targeting For Missile. Compile it and save it.

44. Right now, it wont do anything yet, but what we need is to migrate some highlight
material from the content example sample map. Download the map (the map is quite
heavy 2.5GB, but consider that the highlight feature is not available on UE4 by default).
Then we will continue with this tutorial.

You might also like