Line Trace from Bone Socket (End Trace)

Hey Community,

I’ve already found a way to line trace from a particular Bone Socket. However there is something I would like to know. for example if I have a Socket in the left hand I would like to trace from that bone socket in the direction it is facing as opposed to where my camera is facing, which method is required for this?

I was using the GetActorEyesViewPoint method for my vector & rotation but i’m not so sure that this is the correct method for what i’m asking.

Anyways, thanks a bunch!

#How to Get Direction of a Moving Object

You need to track the object’s position each tick using a PrevPosition variable!

this is

FVector PrevPosition;

Then, each tick, you compare the current and previous position

FVector ObjectMovementDirection = (Actor->GetActorLocation() - PrevPosition).SafeNormal();

FRotator ObjectMovementRotation = (Actor->GetActorLocation() - PrevPosition).Rotation();

  //... do all calculations here

   //before you end function
   PrevPosition = Actor->GetActorLocation();

Note you should initialize PrevPosition to FVector::ZeroVector

and if PrevPosition is ZeroVector, wait till the next tick when it will have a valid previous location.

then after you are done in your function, save off the current position as the new previous

and that is how you get direction of moving objects!

:slight_smile:

Rama

Thanks Rama.

Expanding on the answer…

FVector CameraLoc;
FRotator CameraRot;
GetActorEyesViewPoint(CameraLoc, CameraRot);
CameraRot = Mesh.Get()->GetSocketRotation("Arg");

This is what was needed.