Swap camera onto projectile temporarily

Hi,

I’m in first person with standard camera view, when I press and hold the mouse button I fire a projectile out with varying power. What I want is when I release the left mouse button (which spawns the projectile) I want it to swap to a camera I have set up on the projectile for the duration of it’s trajectory and until it is destroyed, and then swap back to the standard first person view until I fire again.

I can’t seem to get it to reference the new camera so I obviously don’t understand it properly.
This is what I have on the Projectile Blueprint:

Can anyone help me out with this please as I’m sure it’s quite a common feature in many projects.

Cheers

I have been continuing to try different solutions and so far - nothing.
I really thought I had it with this next try, but does…nothing!

Someone take pity on me please?

Should I be doing the camera swap on the level blueprint or the Projectile?
Whichever I try, it doesn’t work.

Seems such a simple thing, swapping a camera but because you can’t reference a component of a blueprint from another blueprint it makes it impossible.

Argh

do the camera swap on the projectile; Event Begin Play —> Set View Target With Blend with New View Target = Self → “Blueprint Sequence” → Before Actor Destroy; Set View Target Blend with New View Target = Player Character.
I just tested and was able to switch camera to my actor and back onto my character no problem.

Hey,
I’m in work at the moment but when I get in I will test this!
When you say “Blueprint Sequence” - is that a node? Not familiar with it.
Is that second set of instructions still to go in the projectile blueprint?
If u have a ascreenshot that would be great. Thx!

Exemple of a sequence: Event Begin Play → branch node → set light intensity. These three nodes create a sequence

So the first bit I can do:

but the second bit needs a ‘TARGET’ plugging in and won’t compile without it, but everything I try is not a valid connection. What do I connect to that?
Here it is so far:

I tried putting Get Player Controller into TARGET , and Get Player Character into NEW VIEW TARGET.
When I fire my projectile, it freezes my controls and at the point I trigger the second ‘Set View Target with Blend’ it goes back to the main camera.
So I think my problem lies with the first Set View Target? As that is the one that doesn’t work properly…

Just some updated screenshots of my projectile. I’m pretty sure the problem lies within these screenshots. The problem is the camera activates but stays where the projectile is spawned rather than following the projectile!

33746-ball3.png

Heeeelp! :slight_smile:

I did some testing and swapping the camera from inside the Projectile itself sometimes gave me odd results when returning the camera. So instead I did the swapping from inside the Player Character and got proper results. I made a short video to help you better visualize.

Camera Swapping Video

Hey, I appreciate the effort and I will try and emulate what you have but because my scenario is quite different to yours I’m not sure if I’ll be able to directly apply the methods you have employed into mine.

It’s so frustrating because literally it all works, even the camera view - but the problem is that the camera stays at the projectiles spawn point rather than following it. Like it’s not attached, but it is attached to the root of the projectile via a spring arm. I have tried it unnatached, attached at different points, with/without the spring arm etc.

Your method feels like I’d be starting again on the player character rather than in the projectiles blueprint and who knows what new problems it will throw up for me? Especially as what you are doing in your (excellent) video is not exactly what I am trying to do!

Don’t wanna sound ungrateful, I appreciate it and I will do a test later to see if I can use what you’ve done but I’m not very hopeful and it seems a shame that I feel so close with what I already have? Somebody must know how to get the camera to follow the projectile?? I’ve tried attaching in different ways with nodes etc but it ignores everything.
argghh

Thx

The only other option at this point would be for you to maybe upload your project somewhere so that I could download and trouble shoot it to see where your problem is. Otherwise it is hard to try and guess exactly what nodes you are using and where. Hopefully you can resolve this soon!

I was hoping the screenshots would be enough. I’m pretty sure nothing is interfering with the stuff I’m trying to do, but yeah I understand that there’s millions of little things spread all over the place and for all you and I know, one of those little tick boxes I’ve checked could be stopping this working.

That being said, the last 5 screenshots above show exactly where I am with it at the moment, and I’m convinced the problem lies within the projectile, either with a setting I have enabled, or incorrect useage of the nodes…
I hate how things are so convoluted at times. This should be an easy thing to achieve and I’m surprised that you are the only person out of all the thousands that have tried helping me!

Cheers
Daz

There isn’t much more to say about camera swapping. That is how it is done. If your problem lies else where, we need more information. For example, swapping camera should not make your character freeze.

Have you tried using The Attach To node or Attach to Component nodes? the Attach To node will let you designate the actor in its entirety and the Attach to Component lets you specifically choose the projectile mesh. Using an event tick to and some flow control to only let the tick set the location when the projectile is spawned could work.

I think when I said it froze, it was before I realised that the camera swap was working after all. It swaps to the camera exactly when it should, and goes back to the 1st Person Camera exactly when it should too.
The problem is only that the camera stays at it’s spawn point and watches the projectile fly off into the distance rather than following it behind as I want it to.
It feels like there’s just that one thing to solve and it’ll be all sorted :slight_smile:

Sorry to frustrate you on this, you’ve been a great help!
Daz

I just tried doing this myself as it seemed like it would be a fun effect and it really is as simple as putting a camera in the projectile root and then using set view target with blend. T he only comment I have to add is that your screenshot of your projectile components above doesn’t actually seem to have a proper root component. As opposed to my projectile:

33893-myprojectile.png

I think if you sort out why that is, you’ll solve the problem.

Target needs to be player controller.

Get Player Controller → Pin it.

Scene Components work fine as Root Components. I myself use the Arrow Component as the root of my actors to get a bearing of my Actor’s orientation. SceneComponent: Has Transform and Supports Attachment

I understand. And first of all, I am not frustrated at all, I am glad to be able to assist you in any way that I can :slight_smile:

I notice that in Ball3 image you have 2 new camera components newvar and newvar0. Could it be that you are setting the camera to these? Your HitCamera should follow your actor. Try removing these new camera components.

On a side note, I realized that you do not need to manually set the camera back to the character. This automatically happens when your projectile gets destroyed.

New Video. Notice that I set up my actor’s components as yours are. Minus the destructible, since I did not have any destructible mesh’s. But my static mesh follows the same hierarchy as in your actor. The only way that I was able to break this mechanic in a similar way that you mention was by creating a new variable of camera actor type and using that to Set View Target with Blend.