Make AS IS object's rotation follow player's foward vector.

I’m trying to think of a way in order to make an object’s current rotation follow the players forward vector, with the exception of the Z axis. So for example:

This is my current code:


The thing Is, I’m not quite sure of how I could do this? Is there a function that does this automatically? I would appreciate some help.

PS: “CapsuleTraceForObjectsWithRotation” is basically the same as “Line Trace By Channel” with the exception that it uses a capsule instead of a dot at the end of the trace.

I may have expressed myself poorly on my last message, however I (sort of) managed to get what I wanted to work.

There’s still an issue though… as you can see, at end of video, when the object is picked up by the player, it will do some sort of “flick”, I’m not really sure what’s causing this.

This is the current code:


Hey @sQuAdeRee!

Have you given this a try, by chance?

Also when grabbing it from different angles, does it spin more? Spin less?

Hi, I’ve already tried this. Unfortunately this method has an issue.

When the object is picked up, the roll, pitch and yawn angles are forcefully reset to, what looks like a pre-determined rotation. Here are 2 examples:

I’m trying to make the object be grabbed “as is” and only rotate the Yawn based on where the player is looking(Basically what I’ve shown in the video on my previous message but without the flickering)

“Also when grabbing it from different angles, does it spin more? Spin less?”

It depends on the angle or side that you’re picking it up, here’s an example:

Hey again @sQuAdeRee!

Ok so I misunderstood the question. You want to use the method I showed above with an additional piece.

Right click in the open and get a “MakeRot” node.
Then grab off of the “HitComponent” or maybe “HitActor” and use “GetWorldRotation”.

Next, right click the pink output and use “Break” to split it into X, Y, and Z.
Now, plug the X and Z in from the OBJECT’s rotation, and use the method you were using on tick (keep that there as well) to grab the camera’s forward and get it’s Yaw to plug into the Y port.

So: MakeRot, X and Z from hit component, Y from camera, into rotation node on “GrabComponentatLocationWithRotation”.

Hi, again. Is this what you meant?

If yes, unfortunately the “flick” is still persistent:

These flicks will only happen only if I move/rotate the object from it’s approximate original location:

Wait a moment. You’re using “HitComponent.”

Try changing all of those outputs from “HitComponent” to “HitActor.”

That seriously may be all it is.

I’ve done this sort of thing before and I used “HitActor”, “HitComponent” would be grabbing all of this data from the component’s point of view not the entire actor’s.

I can only connect “HitActor” to “GetWorldLocation” and “GetWorldRotation”, plus it translates to a root component.

It didn’t change much, everything is still the same.

Ok then. Hmm. So what you need to from here is:
ON TICK WHEN GRABBED ( where you already have shown code) For the “SetTargetLocationAndRotation” You have 0.0. This means “Set the rotation to “0,0, YAW”.”

Also in that earlier post, I forgot Z is Yaw, Y is pitch. So make it should be “Keep X and Y, use new Z”.

But the tick code is setting the new rotation for X and Y to 0, so you need to get the X and Y from the object, as you did in the other code.

1 Like

Yeap, it’s working now… thanks! :slight_smile:

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.