toprakq
Femtopat
- Katılım
- 7 Temmuz 2023
- Mesajlar
- 16
Daha fazla
- Cinsiyet
- Erkek
Kod:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CharacterMove : MonoBehaviour
{
// Start is called before the first frame update
public float moveSpeed;
private Animator anim;
private Rigidbody2D rb2d;
float moveHorizontal;
public bool facingRight;
public float jumpForce;
public bool isGrounded;
public bool canDoubleJump;
PlayerCombat playercombat;
void Start()
{
moveSpeed = 5;
moveHorizontal = Input.GetAxis("Horizontal");
anim = GetComponent<Animator>();
rb2d = GetComponent<Rigidbody2D>();
playercombat = GetComponent<PlayerCombat>();
}
// Update is called once per frame
void Update()
{
CharacterMovement();
CharacterAnimation();
CharacterAttack();
CharacterRunAttack();
CharacterJump();
}
void CharacterMovement()
{
moveHorizontal = Input.GetAxis("Horizontal");
rb2d.velocity = new Vector2(moveHorizontal * moveSpeed, rb2d.velocity.y);
}
void CharacterAnimation()
{
if(moveHorizontal > 0)
{
anim.SetBool("isRunning", true);
}
if(moveHorizontal == 0)
{
anim.SetBool("isRunning", false);
}
if(moveHorizontal < 0)
{
anim.SetBool("isRunning", true);
}
if(facingRight == false && moveHorizontal > 0)
{
CharacterFlip();
}
if(facingRight == true && moveHorizontal < 0)
{
CharacterFlip();
}
Dosya Ekleri
Son düzenleyen: Moderatör: