I would like for some camera shakes to by related to the characters orientation. For instance, when the character slides, the camera should move in same direction as characters forward vector.
Right now the camera shake is defined by a curve. For this shake I have a curve that adds 100 units of location to the cameras X location over a second.
I think the simplest thing to do is to get the player character mesh orientation and use this to rotate the vector that will update the cameras relative location.
The code I have above doesn’t seem to get the characters orientation. As you can see in the gif, the rotation seems to be fixed to world space:
The second camera shake is correct - it moves towards the characters movement direction, but that is just incidental because the vectors are aligned. But I need for the vector to always be rotated in relation to the characters capsule or mesh rotation. FOr instance, if the character is running towards the camera and slides, then the camera should be moving backwards.
I’m not good with math at all, I think I have the right idea about what to do, but not sure how to say it in math terms. Anybody got some tips?
It has to be relative to the characters orientation though, so a simple shake won’t do. The camera is meant to move in same direction as the character mesh in this instance.
yeah so I have a curve that says “over 1 second, move camera in X axis 100 units”.
By default this means camera just always moves along its on X (forward) axis.
But if the character is running towards the camera and slides, then the camera should move in the opposite direction. Or rather, the camera should always move in the direction that the character is sliding.
So we have a curve that tells us what the cameras relative location change should be. That I prefer to stay constant because I have a whole system built around it.
So with that as constant, then I just need to figure out how to say, “given the difference in rotation between the character mesh and the camera, use that difference to align the location delta before applying it as relative location to the camera”
However it’s not working in my full example. Should be able to figure it out though.
The important thing is that we are adding relative location to the camera, we can’t just set it in front of players location. I think the simplest way to say it is that I need to rotate one vector to align with another.
Actually was getting some problems with that setup. The orientation is always correct, however its like 50/50 if the movement happens or not. Cannot figure out why. Its not an execution flow thing, all the nodes firing correctly. Just that sometimes you get the full movement, other times doesn’t seem to move at all.
Well, I figured out an alternate way that seems to work 100% and is a bit simpler:
Since the spring arm is “stuck” to the player mesh anyway, we can actually just move it in world space relative to the player. This is simple enough that I can understand it and accomplishes same task.