(dang, none of my writing saved when I had to sign in…)
My character is in a basic 3rd person setup
So I have an issue in my code.
I am using transform.forward to move my character depending on their rotation. However when it moves forward/back and right/left, I have it turn 45 degrees. I like the way this looks better than a different animation.
The problem is when I do this, the transform.forward is also effected by the rotation offset… Because it is already moving at a 45 degree angle (I am adding transform.right and transform.forward to move) it just ends up just moving to the right…
I don’t know how to really solve this… I was thinking of moving the camera, but I want the camera to dictate the movement of the character, not the other way around.
If this doesn’t make sense, I am trying to move the way fortnite moves (at least how the run forward/right), but I can’t get the transform.forward to ignore the offset rotation… Is there anyway to change this?
Can I make it so I can have an offset to the transform.forward? Would it be better to find a different function to do this? If so, which one? Should I just give up?
This is how I set the target rotation.
NewRot = Quaternion.Euler(NewX, (NewY + strafeOffset), NewZ);
transform.rotation = Quaternion.Lerp(OldRot, NewRot, (Time.deltaTime * rotation));
//NewY is the rotation of the camera, that way it rotates with the camera…
//rotation is the rotation speed.,In my script, the character moves forward based off its rotation using transform.foward.
They are controlled by the camera rotation, so transform.forward was the easiest way for them to move forward based off it’s rotation.
However when they move diagonally, I rotate the character by 45/-45 degrees. This way it looks like they’re running in that direction but still follow the camera. Like Fortnite actually. Sadly, the transform.forward is effected by this rotation, and they end up not moving the way they’re supposed to because of the 45 degree rotation added onto the 45 degree movement I get from the transform.forward and transform.right.
Is there anyway to add an offset to the transform.right? Is it possible to make it so it ignores my rotation offset variable through addition or something? What would be the best way of getting over this issue?