I’m trying to fix the movement on this script, at the present the player moves using WSAD controls, however this movement is not linked to where the player is facing and shooting. Basically at the moment its like a tank.
To achieve this I think I need to link the movement to the variable inputRotation though due to the way this script is set up (Evac-City) im finding it hard to modify this in successfully.
// Use this for initialization
void Start () {
objPlayer = (GameObject) GameObject.FindWithTag ("Player");
objCamera = (GameObject) GameObject.FindWithTag ("MainCamera");
if (gameObject.tag == "Player") { thisIsPlayer = true; }
ptrScriptVariable = (VariableScript) objPlayer.GetComponent( typeof(VariableScript) );
}
// Update is called once per frame
void Update () {
if (health <= 0)
{
removeMe();
}
FindInput();
ProcessMovement();
HandleAnimation();
if (thisIsPlayer == true)
{
HandleCamera();
}
}
void FindInput ()
{
if (thisIsPlayer == true)
{
FindPlayerInput();
} else {
FindAIinput();
}
}
void FindPlayerInput ()
{
// find vector to move
inputMovement = new Vector3( Input.GetAxis("Horizontal"),0,Input.GetAxis("Vertical") );
// find vector to the mouse
tempVector2 = new Vector3(Screen.width * 0.5f,0,Screen.height * 0.5f); // the position of the middle of the screen
tempVector = Input.mousePosition; // find the position of the moue on screen
tempVector.z = tempVector.y; // input mouse position gives us 2D coordinates, I am moving the Y coordinate to the Z coorindate in temp Vector and setting the Y coordinate to 0, so that the Vector will read the input along the X (left and right of screen) and Z (up and down screen) axis, and not the X and Y (in and out of screen) axis
tempVector.y = 0;
inputRotation = tempVector - tempVector2; // the direction we want face/aim/shoot is from the middle of the screen to where the mouse is pointing