Download

Interp problem? (you can help me probably)

Hello everyone, im having problems with interp:
INTRO:

“Current actor Y Degrees” Gives me the actor degrees on the Y axis (0-360 degrees)
“Target Y Degrees” Gives the mouse vector degrees on the Y axis (0-360 degrees)
They both work fine.

PROBLEM:
When I interpolate, the interp never reaches the target degrees…, I tried every interp vinterp finterp rinterp, all was the same, I heard you have to re-feed the current degree? or something like that.

INFO:
-TARGET IS ALWAYS CHANGING
-CURRENT IS ALWAYS CHANGING

It reaches, but it needs some time because the major function of this interpolation - makes something smooth
You can increase interp speed to check it

interp results are stuck between 90 to 250 degrees, it can never reach results between 90 → 250
only moves between 250 → 90, ultra weird

Example of never reaching

Reaches:

I’m using a lot of RInterp and it works fine
Are you using it with event tick?

looks like im running into a gimbal lock problem, which I don’t know how to solve yet, it looks I have to use quaternions but cant find anyplace in the whole internet about how to use them…

Don’t think it works like that in 2D.

think you problem is how you are getting the value for these floats. If you could share that we could be of more help.

you can try this

if interpolated with this

it gets broken, without the interp, it kinda works but you can clearly see the gimbal lock

You are only rotating 1 axis, gimble lock by definition is not possible. :roll_eyes:

IMO this is your problem:
image

you need to project the mouse position to intersect the plane your actors are in. As it is, the mouse position is in a small area in front of the camera component.

this is what it should look like:


The red arrow is the mouse position converted to world intersecting the plane where the other actors are, and that is what they are looking at.

2DRotations

1 Like

hey pezzott1, thank you very much, however, this is how i set this up, given your instructions, maybe I did it wrong, but still not working, I am thinking right now, that maybe this problem happens only on a wall (2d game) and not on a floor (topdown game), because its the pitch that has the problem, maybe you can share your blueprints? you are so kind giving such a full explanation, you are really helping me out, and your expertise shows, thank you again for your time!

And this is my plane:

It doesn’t matter as long as you do your math on the correct axis.

You can use the debug nodes unreal offers to help yourself see the result of your math in the 3d world:

This is how I calculate the position of the blue sphere, where the components on the plane are looking at:

  1. For Line Start got World Location of the mouse is the mouse position in 3D, you need to take the direction vector and multiply it so it intersects with the plane your actors are at. I did * 5,000 to exagerate but you are free to test for Line End as long as it touches the plane.
  2. The Plane Origin is the location of the plane: could be ( 0, 0, 0 ) or where ever yours is in world space.
  3. For the Plane normal I used the Up Vector ( 0 , 0, 1 ) in my case. Since you are looking to the horizon (your game is on a “wall”), think it’s ( 0, 1, 0 ) for you.

I saved it to a variable because I’m reusing it a few times every frame.

So for the different type of rotations:

  1. The basic look at: Used Yaw since I’m top down, you should use Pitch.

  2. this one is a bit more elaborate and as it is rotates at max constant speed:

  3. And finally this is what I think you are after:

The 3 examples are in order of the gif from left to right:

FollowMouse

Even though I used components, all the math is in world space so it’s the same for actors as well.

Hope it helps.

1 Like

Hello again! Pezzottl, interp works, however, it’s still affected by this weird “gimbal lock”, I’m sure pitch is a different story, here is a gif showing the weird rotation, I’m sure this can be fixed, at least movement is solved, so thank you so much, and also the more elaborate way to do it, I was needing that for later anyway so I’m going to sit read understand and then implement it!.

This is the first part of the code
in this part, we get the line that intersects with the plane (i left the debug sphere too) (gif too low q)


the second part
now we just findlookat actor location vector to the intersect vector, and we interpolate.

part2
i tried using set actor rotation but it was worse, the player didn’t even rotate past 90 degrees, which broke the movement , which add force to the forward vector ;
(i tried to copy you as much as i can so its easier for you to read)
and this is the behavior
61cgkq

i am amazed by your dedication.

If you are going to set it to a variable, use the variable for everything else. What ever you connect directly to the intersect node gets calculated again needlesly.

Think this clipping has to do with the sprite fighting with the background to render on top (z fighting). Try separating the plane in Y a bit.

I don’t know why it moves down like that, but doubt it’s the rotation. Imo has to do with how you are moving the plane.

With respect to the variable, yeah I was not going to set it, but afterward, i did and forgot, i will fix that.

To the problem, even when stationary, and the background really far from the plane, it does rotate the same weird way, even with another way of moving the plane it still does, pitch is naturally limited to 90 degrees, even on 2d, i don’t know why.
and yeah the plane falls because it has low speed and high angle of attack, that’s why it moves down and it simulates a stall, but don’t let it distract you, thanks again for your help!
61cjmj

Blockquote

Break the rotation after the interp node and only set the pitch. This will stop the plane from flipping.

Isee you are also using physics. Have you considered moving everything to be on the ground? Should be a bit more “natural”.

1 Like

hey pezzottl, there is no case in trying to remove this lock, I’m moving everything on the ground, at least now we both (and future readers), that if you plan on making a flying game 2D it better be a top down one, side scroller is really hard, i really liked your help, and i hope i can give that favour back in the future!,
Note: on the ground it does work, here is an update:
61eikt
(do not know why its glitching yet!)

1 Like