orientation? I've also been playing some Elden Ring and I like the left right movement where the character will walk in circles.
Vector3 direction = new Vector3(inputVector.x, 0, inputVector.y).normalized;
if (direction.magnitude >= 0.1f) {
// Calculate the move direction based on the camera's orientation
float targetAngle = Mathf.Atan2(direction.x, direction.z) * Mathf.Rad2Deg;
float moveSpeed = speed * Time.deltaTime;
Vector3 moveDir = Quaternion.Euler(0, targetAngle, 0) * Vector3.forward;
Vector3 velocity = moveDir * moveSpeed;
// Ensure we handle collisions with our existing logic
Vector3 finalMovement = ColllideAndSlide(velocity, transform.position, 0, false, velocity);
_rigidbody.MovePosition(transform.position + finalMovement);
}
You will need a way to lock an enemy, then from there you want the intersection points of a circle of diameter 1 around your player and a circle of diameter distance(player, target) centered around the target. From there those two points mark your left and right unit vectors, that should give you a good approximation of elden ring's strafing around enemies
Btw I switch to cinemachine for the camera, I suppose I can just use that as a movement ref?
Yeah, since this type of formula is just indexed on the camera, it basically changes nothing
Обсуждают сегодня