Returning a Projectile to it's origin

Hello!

I’m trying to figure out how to make a projectile act like this:


I want to fire it and then have it return to the source.
In my case the source will be stationary.

All the best!
Daniel

Create a custom projectile blueprint class. Add a variable inside it. It can be a Vector (if your return point does not change), or of Type Actor if your return point changes (for example if you want ti to return to your character).

When the Projectile is spawned, store the return point in the variable we created above (OR store a reference to the Actor to which the projectile should return)

IF you want to return the projectile when it hits something, you must override the OnHit event in the projectile blueprint. Calculate the vector from its current location to the return point (this is where you use the variable we created earlier). This cane be achieved by doing ‘ReturnVector = Return point - Current location’ (IF you are storing the reference to Actor, be sure to use Get Actor Location node).

Once you are here, all you have to do is change the Velocity of the Projectile movement component to BaseVelocity*ReturnVector.

But you will have more control if you dont use ‘ProjectileMovement’ component and instead calculate the movement by yourselves in the tick event of the projectile.

Hope this helps.

Yeah it’s super good, very nice!
Tho I’m to much of a noob in the Blueprint department to set it up I fear!

If you could show me the setup in engine i would appreciate it like hell! :smiley:
But i understand if that’s to much of a time waist! ^^

All the best!

I will try to. But I wont be free until tomorrow. If you can wait, I will post it here tomorrow evening.

Oh thanks you so SO much!
I can absolutely wait, I’m making the FX atm, will give you credit when I post if of course! ^^

Here you go:

You need two BPs:

  1. MyCharacter (extended from Character) I am using the one from ThirdPerson template with some modifications. I added a Fire event on Mouse Button click and defined the listener ■■■ below:

  1. BP_ReturningProjectile (extended from Actor). I defined a custom function Shoot Me and overrode the Tick and OnHit events as below

Notes:

  1. You must create BP_ReturningProjectile first. Otherwsie you wont be able to call ShootMe from charcter blueprint
  2. The graphs are based on another project I am working on. So they are not optimal. There some some unwanted casts and branches. But I am sure you can clean those up
  3. You will need additional logic to do something when it hits an enemy,wall and when it returns to you, Its entirely upto you
  4. Notice that I sued the method where I store the Actor to return to. So this work even if the shooter moves. Again, I am not using the ProjectileMovement component for more flexibility.
  5. You might wan to alter the collision channel settings to suit your needs.

Hope this helps:

The blueprint are self explanatory, I think. If you have any doubts, don’t hesitate to ask

I think i got most of it, a few things im a little iffy on.
Can i add you on skype or something? :slight_smile:

I cannt be on skype. But if you have any doubts, you can find me in the forums. Feel free to PM me.

Sorry for the late reply. I was very busy with something for the last couple of days.

Could you explain how to make the projectile destroy itself after coming back ? I have tried the whole BP but the projectile barely reaches me and gets stuck on the player.

Simplest answer would be to use the ‘Begin Overlap’ event of the projectile and cast the other actor to your character’s class. If its a success, call the destroy node.
However you will need to properly configure the collision channels to generate overlap events.