Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Best approach for to manage the movement and rotation of an attack like dark souls?

Discussion in 'Scripting' started by billygamesinc, Dec 3, 2023.

  1. billygamesinc

    billygamesinc

    Joined:
    Dec 5, 2020
    Posts:
    285
    Rotation/Tracking:
    • Manages the rotation of the attacker to face toward a direction (usually towards its target)
    • Usually decreases over the course of the attack but in some cases increases from 0 value. (AnimationCurve approach is good here imo.
    • Tracking just means how quickly it rotates toward its target while maintaining momentum.
    I'm not sure what the best approach is here but I need to use the set the rotation inside a coroutine with an animation curve. Should I be using Lerp? The attack duration varies.

    Movement:
    • Manages the position of the attacker. Usually towards the target.
    • As stated above the movement value changes throughout the course of the attack/animation
    • Stops the movement on the z/forward position if it collides with a target but maintains its Y and X position.
    For movement should I be using Lerp or transform.position += direction * currentMoveSpeedCurve.Evaluate(). As for stopping the movement, should I use a raycast to check if it ran into something?

     
  2. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    7,238
    Dark Souls and similar games are likely a combination of different approaches, depending on the enemy and requirements.

    In some cases movement will be handled by the animation itself, moving the root object during the animation. Sometimes it will be done via code

    Auto-tracking attacks are likely just using code that rotates the entity towards it's target. Something like a spin attack would be done via the animation itself.

    All in all they would've used whatever was required to get the desired result.

    Just temper your expectations here. Don't expect to achieve the same result as a game like Dark Souls. A solo dev is not going to hit the same quality as a large team of experienced devs in a AAA studio.