Moving backwards

Hello!

I’m just wondering if there is a way of making Ethan moving backward instead of turning around and running towards the camera when you hold down the ‘S’ key.
I’m not looking for a backward-walking animation, just a way of making him moving backward.

Thanks! :slight_smile:
Albin

i believe than you need modify backward animation…because if you hold down “S” and Ethan moving backward, it’s correct but the animation is wrong (in your case).

Hello Manuel and thanks for your reply!

I’m don’t really care about animations at this point. What I want is Ethan to just move backwards in a straight line, and not rotate to face back while ‘S’ is held down.

Perhaps I will try to write my own code to handle player movement as the course goes on.

please help me

my gamepad not working properly
W key and S key is working but
A key and D kay not work

Here My code

using System;

using UnityEngine;

using UnityStandardAssets.Characters.ThirdPerson;

[RequireComponent(typeof(ThirdPersonCharacter))]

public class PlayerMovement : MonoBehaviour

{

[SerializeField] float walkMoveStopRadius = 0.2f;

ThirdPersonCharacter m_Character;   // A reference to the ThirdPersonCharacter on the object

CameraRaycaster cameraRaycaster;

Vector3 currentClickTarget;

bool isInDirectMode = false; // ToDo censdier macking static leter 

private void Start()

{

    cameraRaycaster = Camera.main.GetComponent<CameraRaycaster>();

    m_Character = GetComponent<ThirdPersonCharacter>();

    currentClickTarget = transform.position;

}

// Fixed update is called in sync with physics

private void FixedUpdate()

{

    if (Input.GetKeyDown(KeyCode.G)) // G for gamepad // TODO add manu      

    {

        isInDirectMode = !isInDirectMode; // toggle mode 

    }

    if (isInDirectMode)

    {

         ProcessIndirectMovement();

    }

    else

    {

        ProcessMouseMovement();

    }

}

private void ProcessIndirectMovement()

{

    print("Direct movement");

    float h = Input.GetAxis("Horizontal");

    float v = Input.GetAxis("Vertical");

    print(h = v);

    // calculate camera relative direction to move:

    Vector3 m_CamForward = Vector3.Scale(Camera.main.transform.forward, new Vector3(1, 0, 1)).normalized;

    Vector3 m_Move = v * m_CamForward + h * Camera.main.transform.right;

    m_Character.Move(m_Move, false, false);

}

private void ProcessMouseMovement()

{

    if (Input.GetMouseButton(0))

    {

        print("Cursor raycast hit layer" + cameraRaycaster.layerHit);

        switch (cameraRaycaster.layerHit)

        {

            case Layer.Walkable:

                currentClickTarget = cameraRaycaster.hit.point; // So not set in default case

                break;

            case Layer Enemy:

                print("not moving to enwmy");

                break;

        }

    }

    var playerToClickPoint = currentClickTarget - transform.position;

    if (playerToClickPoint.magnitude >= walkMoveStopRadius)

    {

        m_Character.Move(playerToClickPoint, false, false);

    }

    else

    {

        m_Character.Move(Vector3.zero, false, false);

    }

}

}

The third person controller was used in the old RPG course, but I’ll try to help out… What specifically isn’t working about the A and D keys?
The THC is designed so that W and S are forward backwards, and A and D strafe left and right (the character doesn’t turn, but instead moves to the left or right of the forward direction without actually turning). Turning is managed by moving the mouse.

any other way to fix it
please explain other code for move perfect
thank you sir

Privacy & Terms