void move() { movex = Input.GetAxis("Horizontal"); //movey = Input.GetAxis ("Vertical"); we'll use this later for ladders //Set run animation based on input ThisAnimator.SetFloat("speed", Mathf.Abs(movex)); //Tell animator the Y velocity ThisAnimator.SetFloat("ySpeed", rigidBody.velocity.y); if (Mathf.Abs(rigidBody.velocity.x) > 0 && !audioSource2.isPlaying) { //audioSource2.Play (); } else if (Mathf.Abs(rigidBody.velocity.x) == 0) { //audioSource2.Stop (); } if (canMoveX) { rigidBody.velocity = new Vector2(IsBlocking? movex * blockSpeed : movex * characterStats.MovementSpeed, rigidBody.velocity.y); } float x = transform.localScale.x; if (movex > 0 && x < 0) { transform.localScale = new Vector3(-transform.localScale.x, transform.localScale.y, transform.localScale.z); } else if (movex < 0 && x > 0) { transform.localScale = new Vector3(-transform.localScale.x, transform.localScale.y, transform.localScale.z); } }
public void Move() { //Currently can only move if he is not attacking if (!IsAttacking) { //Tell animator that we are moving ThisAnimator.SetFloat("movementSpeed", 1); playRunSoundNearPlayer(); //Translate transform.Translate(new Vector3(1 * (characterStats.MovementSpeed * Time.deltaTime), 0, 0)); } }
/// <summary> /// Author: Ziqi /// Implementation of abstract method to trigger moving /// </summary> public override void IsMoving(float speed) { ThisAnimator.SetFloat(ParamName_Moving, Mathf.Abs(speed)); }
public void StopMoving() { audioSource1.Stop(); ThisAnimator.SetFloat("movementSpeed", 0); }