Search Unity

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

Cyberpunk Monowire in Unity

Discussion in 'General Discussion' started by denali95, Apr 6, 2023.

  1. denali95

    denali95

    Joined:
    Nov 6, 2016
    Posts:
    78
    I'm trying to recreate something like the Monowire from Cyberpunk 2077 (for reference: Mantis blade SO overrated. Monowire is WAY better. - YouTube). This is similar to a whip in a first person game. I'm guessing to implement this, you'd want to do the physics calculations to find out the trajectory of where a rope would naturally go if one whipped it, then use a line for the visual. Is there an easy way to handle this?
     
  2. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,484
    Cyberpunk Monowire definitely does not simulate whip-like behavior. It works like a typical melee weapon. Meaning when animation plays, the game performs overlap check in predefined collision area, and hits whatever is inside of it.

    So, if you want a whip, the whip will be driven by your animation, and you'll know where the animation is going to go.

    Unless you're dealing with VR, this will be sufficient.

    However, if you REALLY want to simulate a whip/rope and REALLY want to predict where it is going to go....
    You'll have to manually simulate its movement in your code, just like you'd be running the simulation. In this case the whip can be represented as a spring-based particle system, and by running it for a while at fixed step, you'd be able to predict the trajectory, though accuracy will be uncertain.

    The reason why I suggest particle is because they do not have rotation and can be simulated using standard
    F = ma,  x1 = x0 + v*t + a*t*t/2
    and velocity/acceleration equations for that are part of school course.

    You can find more about it if you read, for example, Chris Hecker's papers on Rigid Body dynamics.
     
    Ryiah likes this.
  3. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    10,019
    The monowire, iirc, just uses pretty standard collision meshes that line up with where the animations go. The attack animations were pretty much all canned, so they just had a collision mesh that represented each. If you wanted to be a little extra in your implementation and go for a whole physics approach, you could make a series of raycasts that follow segments along a curve. It wouldn't need to be terribly accurate, just a few subdivisions.
     
    Ryiah likes this.