Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

300
Vistas
How to move player using rigidbody.moveposition but move player where he is looking and according to that move player?

Here is my player controller script till now.. '''

//Variables
public float speed = 5f;
public float sprintSpeed = 10f;
public float jumpForce = 10f;

private Rigidbody rb;

//Methods
private void Start()
{
    rb = GetComponent<Rigidbody>();
}
private void FixedUpdate()
{
    BasicMovement();
}
void BasicMovement()
{
    //Get Player Input
    float inputX = Input.GetAxis("Horizontal");
    float inputZ = Input.GetAxis("Vertical");

    //Get where is Player moving position
    Vector3 direction = new Vector3(inputX, 0f, inputZ);

    //Move Player
    rb.MovePosition(transform.localPosition + (direction * speed * Time.deltaTime));
}

'''

The cam controller script: ''' //Variables public float mouseSensitivity = 100f; //Mouse Sensitivity Variable so that i can change it later to my liking public Transform playerBody; //So camera knows what is the player body private float xAxisRotation; //To move in the x axis

void Start()
{
    
}

void FixedUpdate()
{
        Cursor.lockState = CursorLockMode.Locked; //Locks mouse cursor at the center of the screen
                                                  //Get Mouse X,Y positions in variables
        float mouseX = Input.GetAxis("Mouse X") * mouseSensitivity * Time.deltaTime; //Gets mouse location at the x-axis
        float mouseY = Input.GetAxis("Mouse Y") * mouseSensitivity * Time.deltaTime; //Gets mouse location at the y-axis

        xAxisRotation -= mouseY; //-ensures the rotation is not flipped
        xAxisRotation = Mathf.Clamp(xAxisRotation, -90f, 90f); //Clamps rotation to -90, 90 so that player cannot look behind

        transform.localRotation = Quaternion.Euler(xAxisRotation, 0f, 0f); //I dont know

        //Implement mouseX position to playerBody so that the entire player moves in the X-Axis
        playerBody.Rotate(Vector3.up * mouseX);
}

'''

If you need something else plz tell.

over 4 years ago · Santiago Trujillo
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda