Y rotation value going from 0-90-0 and switching x and z values to 180

Hi,

I’m trying to make a trident for my final boss where I use Find Look At Rotation so that the trident faces the player when the player moves. I have two problems that are happening though and I think that they’re related.

  1. When the player is directly below the trident, it flips (instead of staying straight and moving with the player to make a 360 degree turn). Keep in mind this is a 2D side scroller.

  2. When I rotate the trident, the y value goes from 0 to 90 and then back to 0 when it should be 180 degrees…it adds 180 degrees to both x and z values instead of keeping them 0 and increasing y.

I think that the problems are connected.
Thank you for your help in advance.

1 Like

Take a look at my answer to this post

It’s because rotation is not as simple as it seems :slight_smile:

1 Like

Hi,
I know you’re probably really busy so thanks for responding. If you don’t mind, what is a local rotation? And instead of breaking them up should I use break rotator node?
I asked ChatGPT for help and he said the same quaternion idea but I don’t know how to implement it. With nodes? Parent class?
Thank you

1 Like

So, the solutions go like htis

1 Only add to local rotation using nodes like this

You can just keep adding rotation in any direction, and it will never snap through 180, because the system understands about this rotation problem. But, this is only suited to some applications, like a spaceship.

2 You can add rotations together, but you have to only do it with rotator nodes. No splitting nodes open, that’s causing the problem. Let’s say you want to use look at rotation, but also add some amount in one axis ( something like the trident swinging downwards ). This just points the trident at the player ( assuming the pivot, and hence X axis, is facing the correct way )

But, if you want to swing it downwards ( or across ), you might use a timeline with a rotator, and you can add those like this

Notice it is ok to break nodes just to make a rotator variable, as long as you use ‘combine rotators’ to do the math.

Also, I doubt this will literally work, its just an example. But it will maintain ‘look at’ while moving through 90 in Y.

Also, there is the issue of working with local or world rotation, you have to pick one, you can’t combine them :slight_smile:

3 Use quaternions. That’s a whole other subject. They don’t have the snapping problem, but you have to get your head around them first.

1 Like

I’m really sorry for wasting your time but I just don’t get add local rotation. Should it be before set world location or replace it? Also I tried the timeline and the trident didn’t move unfortunately.
Thank you.

1 Like

Like I say, in your case, add local rotation is not the answer.

Can you show the code you have?

1 Like

Yes definitely.

And the timeline

By the way, it’s not an instant flip. If I move extremely slowly I can see that it flips on a 3d scale and it looks glitchy when done in normal speed. Also, the timeline simply didn’t move the trident.

Thank you.

1 Like

Ok, so nothings calling the timeline?.. It needs a curve inside the timeline

Also, how is all this hanging together? What’s calling ‘trident rotation’?

1 Like

I’m sorry I didn’t know you wanted the whole entire code, here it is:

1 Like

Nothing is calling this code

It’s also way too much code, you only need a handful of nodes to get it working.

Sorry, it’s very hard to troubleshoot this from a distance.

1 Like

You’re right, it’s way too much for the trident, however that’s for other animations. Everything in that section and the one on the right have nothing to do with the rotation. I’m sorry for the confusion I should have been clearer. The only two sections that serve a purpose are the function and timeline.

1 Like

If you have a swing animation, you only need the play node.

I had a quick look for weapon control blueprints, it’s all just triggering animations.

1 Like

Yes, the weapon control are animations as they were made not as an attack but to trigger a lava event. The rotation that I’m trying to reach is similar to the guardian from BOTW - it points at the player for a period of time. The only problem I’m facing is that if I only use the Y value, it flips into 3d and doesn’t work. Same goes for X and Z rotation values.

set timer by function name → delay 3s → clear timer by function name → play another animation

Ok I just adjusted something and it works a little bit better now, instead of hooking up X and Z values in the TridentRotation function, I left them as 0.0 so now they always stay 0. Slight problem though - when it reaches 180 on the Y axis, it reverses and goes back instead of continuing to go 360. So like this:

\ → | → \

instead of what I want which is:

\ → | → /

I’m going to try and fix it
Thank you so much for your help ClockworkOcean. And I apologize for being quite confusing.

1 Like

I found a solution that kind of works.
Here is is:

For some reason, below the “Cross Vector Vector” node it says subtract…but it’s actually a dot product, not subtraction.

Thank you.

1 Like