using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PLayermovement : MonoBehaviour {
public Animator anim;
public Rigidbody rb;
public bool StickyonGround = true;
public bool GuyMoving = false;
private void Start()
{
rb = GetComponent<Rigidbody>();
anim = GetComponent<Animator>();
}
// Update is called once per frame
void FixedUpdate()
{
if (Input.GetKey(KeyCode.S))
{
transform.Translate(0.0f, 0f, -1f);
anim.Play("Running Backward");
GuyMoving = true;
}
if (Input.GetKey(KeyCode.W))
{
transform.Translate(0.0f, 0f, 1f);
anim.Play("Running(1)");
GuyMoving = true;
}
if (Input.GetKey(KeyCode.A))
{
transform.Translate(-1f, 0f, 0f);
anim.Play("Running(1)");
GuyMoving = true;
}
if (Input.GetKey(KeyCode.D))
{
transform.Translate(1f, 0f, 0f);
anim.Play("Running(1)");
GuyMoving = true;
}
if (Input.GetKey("space") && StickyonGround) {
Debug.Log("Jump");
rb.AddForce(new Vector3(0f,10f,0f), ForceMode.Impulse);
StickyonGround = false;
anim.Play("Jumping Up");
}
GuyMoving = false;
if(Input.GetKeyDown(KeyCode.F))
if(GuyMoving == false)
{
anim.Play("Happy Idle");
}
}