Thisislike
usingUnityEngine;publicclassPlayerMovement:MonoBehaviour{voidAwack(){floorMask=LayerMask.GetMask("Floor");
anim = getComponet <Animator> ();
playerRigidbody = GetComponent <Rigidbody> ();
}
void FixedUpdate ()
{
float h = Input.GetAxisRaw ("horizontal");
float v = Input.GetAxisRaw ("vertical");
Move (h, v);
Turning ();
animating (h, v);
}
void (float h, float v)
{
movement.Ser(h,0f,v);
movement = movement.normalized * speed * Time.deltatime;
playerRigidbody.MoviPosition (transform.position + movement);
}
void Turnig ()
{
Ray camRay = Camera.main.screenPointToRay(Input.mousePosition);
RaycastHit floorHit;
if(Physics.Raycast(camRay,out floorHit.camRayLenght.floorMask))
{
Vector3 playerToMouse = floorHit.point - transform.position;
playerToMouse.y = 0f;
Quaternion newrotation = Quaternion.LookRotation(playerToMouse);
playerRigidbody.MoveRotation(newrotation);
}
}
void animating(float h,float v)
{
bool walking = h != 0f.v!=0f;
anim.SetBool("IsWalking",walking);
}
}