Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question How collision can be handled when CharacterController is rotated ?

Discussion in 'Physics' started by Dragoon-scales, Jan 6, 2023.

  1. Dragoon-scales

    Dragoon-scales

    Joined:
    Jul 6, 2019
    Posts:
    9
    Hi,

    I am trying to reproduce the anthem flying mode and one thing to note is that when flying, the character is horizontal (vs vertical when walking).

    However, due to the nature of the built-in CharacterController, the collision capsule can't be rotated in X or Z axis. Moreover in this talk, the devs say that the capsule is rotated only in the Y axis as well.

    So, when flying how the collisions are handled?
    As the capsule doesn't encompasses the whole character, how does it properly collide with walls for example.

    Thanks
     
  2. lightbug14

    lightbug14

    Joined:
    Feb 3, 2018
    Posts:
    446
    My guess is that this is 100% animation. For instance, you could animate the character flying up and down, and then put those clips inside a blend tree. At the physics level, the capsule goes up and down but it doesn't rotate (pitch/roll).
     
    Dragoon-scales likes this.
  3. Dragoon-scales

    Dragoon-scales

    Joined:
    Jul 6, 2019
    Posts:
    9
    Thanks for the reply, but then how do you prevent going into walls ? (Visually)
    As the capsule would collide with a wall after the character “enter” into it. Would it still be with animations ?
     
  4. lightbug14

    lightbug14

    Joined:
    Feb 3, 2018
    Posts:
    446
    I think i would either:
    a) add an extra capsule collider and rotate that with the model. By having this extra collider, i can (for example) compute the penetration and maybe push back the whole character.... or
    b) dynamically increase the radius of the controller (from upright capsule to sphere and vice versa) in order to match the horizontal pose. Probably not a great idea, but it might work.
     
    Dragoon-scales likes this.
  5. Dragoon-scales

    Dragoon-scales

    Joined:
    Jul 6, 2019
    Posts:
    9
    Okay it seems right, thank you for your help !
     
    lightbug14 likes this.