So my script for movement works as follows.
the problem is that even thought i watch horizontalaxis and verticalaxis working correctly in the inspector
the animator floats do not always have the proper value and basically only work when the number is a positive number and seems to not work with negative numbers at all.
So far iv’ tested and the vericalaxis and horizontalaxis operate correctly going from positive to negative depending on the input and can be seen working during test plays in the inspector
but the animator will not change the number to a negative one for the animator floats “turning” and “walkstate”
double checked the spelling on both and its correct
however i can manualy change the values in the animator to negative ones
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityStandardAssets.Characters.ThirdPerson;
public class combatmovement : MonoBehaviour {
public bool combatmoving;
public float speed = 6.0F;
public float jumpSpeed = 8.0F;
public float gravity = 20.0F;
public float walkspeedstat;
public Animator anim;
private Vector3 moveDirection = Vector3.zero;
public float horizontalaxis;
public float verticalaxis;
public bool canmove;
void active()
{
if (GetComponent<Targeting>().cameraturnon == true)
{
GetComponent<ThirdPersonUserControl>().enabled = false;
combatmoving = true;
}
else if(GetComponent<Targeting>().cameraturnon == false)
{
combatmoving = false;
}
}
void moving()
{
CharacterController controller = GetComponent<CharacterController>();
moveDirection = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
moveDirection = transform.TransformDirection(moveDirection);
moveDirection *= walkspeedstat;
walkspeedstat += 0.000000001f;
if (controller.isGrounded)
{
if (Input.GetButton("Jump"))
{
}
}
}
void axiscount()
{
horizontalaxis = Input.GetAxis("Horizontal");
verticalaxis = Input.GetAxis("Vertical");
}
void movement()
{
if (canmove == true)
{
CharacterController controller = GetComponent<CharacterController>();
moveDirection = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
moveDirection = transform.TransformDirection(moveDirection);
moveDirection *= walkspeedstat;
walkspeedstat += 0.000000001f;
if (controller.isGrounded)
{
if (Input.GetButton("Jump"))
{
}
}
}
if (Input.GetAxis("Horizontal") > 0)
{
anim.SetFloat("Turning", horizontalaxis);
}
if (Input.GetAxis("Vertical") > 0)
{
anim.SetFloat("WalkState", verticalaxis);
}
}
// Use this for initialization
void Start () {
anim = GetComponent<Animator>();
canmove = true;
}
// Update is called once per frame
void Update () {
axiscount();
movement();
active();
}
}