Hii, so…
Ok, I’m going to get to the point. The playerController I’ve made works great, except for one huge bug… First I have to explain how it works. It is a third person game, where the camera is fixed (Like the old Resident Evils, Silent hill or the new Tormented Souls game) so when you move the Stick or the WASD the character moves, but the 3D model doesn’t rotate. I tried to make it rotate on the same GameObject but it didn’t work. So I called the 3D model and made it rotate instead of the Player, giving the Illusion that the character rotated. This worked, and didn’t give me any problems until I got much further into the project, until I put the camera somewhere else and it felt weird handling the character. Obviously (Assuming the camera was facing the Player) the Player was inverted, if I pulled the stick to the left, the Player went to the right… And I couldn’t think of anything to fix it.
I leave the lines of code right here, plus 2 videos. One showing the problem and the other is a Tormented Souls Gameplay, the move I want to achieve.
Pd: Some variables are in Spanish XD my native language.
Tormented Souls:
My video of the problem: https://youtu.be/FX4lWd-w7Ko
In the video, the screen of the Editor, if I move the stick to the left, the player moves to the left, but in the Game window it does not happen (which is what I want to happen)
//Gravedad
if (cc.isGrounded)
{
move.y = 0f;
}
else
{
move.y -= gravedad * Time.deltaTime;
}
//Caminar
move = new Vector3(I_Moverse.ReadValue<Vector2>().x, move.y, I_Moverse.ReadValue<Vector2>().y);
//Girar en direccion del Stick
if( move.x != 0 || move.z != 0)
{
Vector3 lookdir = new Vector3(move.x, 0, move.z);
Quaternion toRotation = Quaternion.LookRotation(lookdir);
HANNA.rotation = Quaternion.RotateTowards(HANNA.rotation, toRotation, girarvelocidad * Time.deltaTime);
}
//Correr
if(I_Correr.ReadValue<float>() > 0 && (move.x != 0f || move.z != 0f))
{
move = transform.TransformDirection(move) * corrervelocidad;
isRunning = true;
}
else
{
move = transform.TransformDirection(move) * caminarvelocidad;
isRunning = false;
}
cc.Move(move * Time.deltaTime);
HANNA is the model 3D, and is child of the Player
7940326–1015576–TPC.cs (3.28 KB)