private void FixedUpdate() { Velocity = Vector2.zero; if (inputMove >= 0) { walkDir = inputMove; walkAngle = Angles.GetAngle(inputMove); inputMove = -1; Velocity = Angles.GetDirection(walkAngle) * moveSpeed; swordAnchor.rotation = Quaternion.Euler(0f, 0f, Mathf.Rad2Deg * walkAngle); } rb.MovePosition(rb.position + (Velocity + (hitNormal * bounceForce)) * Time.fixedDeltaTime); hitNormal *= forceFalloff.Evaluate(Mathf.Clamp01((Time.time - hitTime) / 1f)); }
private IEnumerator Move(int angleIndex) { Vector2 length = Angles.GetDirection(angleIndex) * moveLength; Vector2 startPos = transform.position; float startTime = Time.time; while (Time.time - startTime < moveDuration) { float dt = (Time.time - startTime) / moveDuration; float pos = positionOverTime.Evaluate(dt); transform.position = startPos + (length * pos); yield return(null); } transform.position = startPos + length; onFreeCoord.Invoke(startPos); onOccupyCoord.Invoke(transform.position); }
private Vector2 GetVelocity() { return(Angles.GetDirection(angle) * speed); }