4月16日
movement的关键是通过接触的判断来对玩家的不同状态进行判定,比如说,在墙上,不在墙上,在地面上,不在地面上,是否在冲刺,对状态区分的细致程度决定了你游戏的操作手感
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Movement : MonoBehaviour
{
private Rigidbody2D rb;
private Animator ani;
private Collision coll;
public float speed = 4;
public float jumpForce = 8;
public float wallJumpLerp = 4;
public float jumpTime = 0;
public int jumpCount = 1;
public float dashSpeed = 20;
public float slideSpeed = 5;
public bool isJump = false;
public bool canMove;
public bool wallGrab;
public bool wallJump;
public bool wallSlide;
public bool isDashing;
private bool groundTouch;
public bool hasDashed;
public int side = 1;
// Start is called before the first frame update
void Start()
{
canMove = true;
rb = GetComponent<Rigidbody2D>();
ani = GetComponent<Animator>();
coll = GetComponent<Collision>();
}
// Update is called once per frame
void Update()
{
}
private void FixedUpdate()
{
float x = Input.GetAxis("Horizontal");
float y = Input.GetAxis("Vertical");
float xRaw = Input.GetAxisRaw("Horizontal");
float yRaw = Input.GetAxisRaw("Vertical");
Vector2 dir = new Vector2(x, y);
Move(dir);
if(rb.velocity.x <