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