Diagonal character movement
I know a lot of these questions exist and have been answered but I couldn't find the answer for my code structure so if anyone knows a simple fix pls tell me. Code:
private void Movement(float v, float h)
{
if (h != 0f || v != 0f)
{
rotate(v, h);
transform.Translate(Vector3.forward * movementSpeed * Time.deltaTime);
}
else
{
transform.Translate(Vector3.zero * movementSpeed * Time.deltaTime);
}
if (Input.GetButtonDown("A") && isGrounded)
{
Jump();
}
}
You didn't even tell what you are trying... and what are "these questions"? Could you clarify what you are trying to do? Seems like you are doing 2D platformer (you have jump) but then you try to rotate (?) your transform, and then move it... If you just need to move your character diagonally, you can create a vector3 out of x and y input, then use it in your translate.
Sorry for a late reply I was busy, but what I'm trying to achieve is simple 3D third person movement but my character moves faster diagonally and all the fixes for this I found were for a different code, I was wondering how could I fix it with this code, I heard someone say use this:
Vector3.Clamp$$anonymous$$agnitude()
but how?
Your answer
Follow this Question
Related Questions
Player teleport not working 0 Answers
GameObject doesn't move 1 Answer
transform.Translate is too smooth 3 Answers
Move Character in the way he is facing.,Make character move in way he is facing. 1 Answer
transform.translate limits 1 Answer