Untitled
unknown
plain_text
a year ago
1.1 kB
13
Indexable
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.VFX;
public class PlayerCombat : MonoBehaviour
{
[SerializeField] private Animator anim;
[SerializeField] private Transform playervisual;
private Vector3 playerscale;
private const string WALK_PARAM = "IsWalking";
private const string ATTACK_PARAM = "IsAttacking";
// Start is called before the first frame update
void Start()
{
playerscale = playervisual.transform.localScale;
}
// Update is called once per frame
void Update()
{
float x = Input.GetAxis("Horizontal");
anim.SetBool(WALK_PARAM, x != 0);
if (Input.GetKeyDown(KeyCode.F))
{
anim.SetTrigger(ATTACK_PARAM);
}
if (x > 0)
{
playervisual.transform.localScale = playerscale;
}
else if (x < 0)
{
playervisual.transform.localScale = new Vector3(-playerscale.x, playerscale.y, playerscale.z);
}
}
}Editor is loading...
Leave a Comment