Pointers for camera location?

Hi there. When I was making my camera, I used UpdateViewTarget like in UDK. But in UDK I attached it to a socket in the player’s Mesh. In my case the Mesh1P. How do I make the OutVT.POV.Location that of the mesh1p socket’s location? I tried using pointers, and i know that’s the way to go, but I am confused on how to use. I keep getting errors.

Hi Eshwar,

You can use GetSocketLocation/GetSocketRotation or GetSocketTransform on the skeletal mesh component that contains your socket.

Cheers,
Michael Noland

I tried getsocketlocation but how do I use it in the camera class. Don’t I need pointers?

Could you post a little more information about exactly what you’re trying to do? (implementing which function in what class, and which class contains your Mesh1P component)

Cheers,
Michael Noland

I was doing a true fps. And for that in UDK i used UpdateViewTarget and the location was as you said Pawn.Mesh1P.GetSocketLocation(TheSocket). But here in C++ I am not familiar on how to approach this. I think it is with pointers from what I have heard but I dont know much about them.

Hi Eshwar,

Assuming you are overriding APlayerCamera::UpdateViewTarget, and the view target is your Mesh1P or whatever:

const FVector SocketPos = OutVT.Target->GetRootComponent()->GetSocketLocation(TEXT("MySocketName"));
// Do some math to arrive at OutVT.POV.Location based on SocketPos

If the Mesh1P is attached to the view target, but not the root component, it’d look something like:

if (ASomeClass* TypedTarget = Cast(OutVT.Target))
{
	const FVector SocketPos = TypedTarget->Mesh1P->GetSocketLocation(TEXT("MySocketName"));
	// Do some math to arrive at OutVT.POV.Location based on SocketPos
}

Cheers,
Michael Noland

there you go thank you very much. I tried the first but I need to do some math. The second though it says Mesh1P is protected so I cant access it. Perhaps getSkeletalMeshComponent? Any help with the second because that is the suitable one I think

If you are working off of ShooterGame, Mesh1P is also the root component, so you can use GetRootComponent instead, or you can make an accessor function for Mesh1P, or make it public.

Cheers,
Michael Noland

Thank you very much. :slight_smile:

Now that it matches the location i set the rotation to match the socket rotation as well. Only problem is that I cant aim up or down i can only turn. I dont understand. I think its because the pawn follows the socket rotation so it needs to rotate on its own. But then how does it turn sideways?? Sorry for asking a lot of nooby questions.

Hey Eshwar, no worries asking “nooby” questions. We all get stuck from time to time! To try and help further, and to assist anyone in the future that is trying to do the same thing, can you let me know what documentation you would need in order to achieve your desired result?

Keep in mind, documentation isn’t always going to tell you exactly how to make something, but it should definitely get you in the right direction. Do you feel something was missing that could have helped you here?

Ok but can you help because it wont rotate pitch it will only yaw

When i use getsocketlocation it doesnt work the aim is messed up. It matches the location but when aiming down or up it doesnt move with head?

The socket is attached to a bone. Which bone are you using, and what does the animation that you are playing do to it?

If the bone doesn’t change orientation when aiming up and down, then the socket won’t either.

Cheers,
Michael Noland