Download

Moving Camera On the fly

So I am trying to move my camera to a socket created on a rifle

componant.png

I have been able to print out the sockets location

ar_blue.png

But i have no idea how to move my camera to the socket and follow it

7e4410d89292ea6262ca5510a2f493bcb4e6ba5b.png

I am trying from my base player controller

this is what I am trying to do but am really lost SEE FORUM LINK HERE

Maybe with set relative location?

https://answers.unrealengine.com/questions/298334/how-to-move-camera-with-blueprints.html

@unit23

Maybe… but thing is i cant access the data! How would i get the data into or from the player controller?

If you access a player controller, make a Cast to PlayerControllerName, with Get Controller, then a node for Set Relative Location.

I did try that, but i get the following Cast will always fail error

91443ae11cf993b7d6a98131dc5a2c879e1f7ae3.png

9510c67e4ff5f685e9a6f256ecc63ed2a7dab040.png

Use a key input on your event graph, seems you fixed the object error.

one step ahead of you!

All it prints is x y and z at 0.0

a69f43fbf50e5f536772a547f1ada654c09ccaca.png

And the same here

217f20816716bda428b43addec702ae55917e7c5.png

sight.png

I see that Sight is a variable in both your gun blueprint and your character controller.

It looks that Sight is never assigned in your character controller, hence the None error.

Does your player controller own a reference to your gun blueprint? If so, you would use that reference variable and then get the Sight variable from the gun blueprint.

Ok so created a Vector called SightLocation in the assault rifles blueprint and made it public…
I fed in the Sights Relative Location to the Variable (which is containing the data)

AR BP.png

I tried to pic the variable up from the player controller but i cant

Sight to screen.png

This is starting to drive me a bit bonkers

On that Error node, it is trying to get a Sight Location variable owned by BasePlayerController, but it is actually part of AR_Blueprint. Therefore in BasePlayerController, you need a variable that holds a reference to AR_Blueprint.

How do you attach your gun to your character? Do you spawn an actor based on AR_Blueprint?

This is how its done

d4dd295890468c2a911544033958c2df91acea2c.png

I created the AR Ref but it didnt help

See that return value from spawn actor for AR_Blueprint. Plug that into a Set for Ar Ref.

AHHHHHHHHHHHHHHH

Love you man! Thanks alot!!!

Well great that i got the sockets location but now when i try to use it it goes about 20ft into the air!!

Whats up with that? You can see the socket at the top of this thread

fe2091fb471232ec2f29a1817dcf531214a9c86b.png

Its supposed to attach the camera to the socket placed just on the weapons iron sight, but it ends up up here instead

upview.png

What is the name of the socket you created on the gun? I think you have to put that socket name in the In Socket Name part on the get socket location.

I tried that… put the name in, camera moves just a touch forward so i thought “Ahh ok, im moving the camera but the boom is still the same” so i set the boom to 0 and the camera went up my guys ***!

God dam this S*1ts hard!!!

I dunno

Im sure i get the concept of what i want to do but how to do it is killing me

If your camera has a boom, that is what you want to place in the gun socket, since the camera is a child of the boom, the camera will move appropriately if you move the boom. Then if you want the camera right on the spot, you would set the Arm Length of the boom to 0.

I’m assuming your weapon has a skeletal mesh component? If so, on the Get Socket Location, you actually want to put the target as the weapon’s skeletal mesh component, not that Sight variable. And then it will find the socket on the gun mesh.

Well I finally got it done!!!

https://youtube.com/watch?v=dharcRzBABI

To everyone who helped me both on this and my other thread (where i wanted to explode my computer and never hear the name UE again), I give a HUGE thank you to you… @ToxinGaming patient life saver!

Well, until I get stuck again, (I expect in about 3 mins), cheers for now and again thank you!

I’m glad you were able to get that done. Next you’ll probably want to make sure that left hand is locked onto the rifle. Information on how to do that located here.