How do I create a capsule for a animal (ex. wolf) character?

Hey Guys,

I just started to work on our new, in which a wolf plays the main character. This is kind of tricky, because the wolf doesnt really fit into a the vertical capsule. We are now thinking to have two horizontal capsules, which would fit the wolf best and then write our own movement component in cpp.
This would be quite a bit of work, so if anyone has a good idea or different solution to this problem?
Thanks in advance

Yeah best thing is to create your own Character Class. There you can just make your Capsule smaller or rotate it a by 90° to fit your Wolf Mesh. I don’t think you would need 2 Capsule. 1 should be enough if you just turn it and scale it a bit.

Hi,

thats what I tried, but unfortunatly I cant add a second collider. The collision always happens only between the first collider and the world. The second collider has no effect.
I was thinking to have a small capsule and then use the physic asset tools for all the body parts that are outside the capsule. That should work fine in theorie but there are no collisions happening either with the mesh?
Any ideas.

The mesh it self has no collision. You need would need to create a basic collision in your 3D Model Programm and export it with him. There are tutorials on Youtube on how to do this.

Still, you should be able to use a second capsule. You need to check if the collision settings are correct. You could compare them to the original capsule.

You should also be able to modify the Character class as far, that you can change the original capsule. This requires some c++ though.

Hi ,

You can also adjust the size of the Capsule by adjusting the Capsule Half Height and Capsule Radius (shown in gold). Then you can add custom collision to individual joints on your skeletal mesh (shown in red) like on the wolf’s head, legs, and hips.

Hope this helps!

1 Like

The problem is, he wants to have a horizontal capsule and editing these 2 parameters will only result in a round capsule or a vertically scaled one. He would need to rotate the capsule, but thats not possible, since it is a Root Component.

I mean, he could rotate the mesh by 90° so that it faces “up” with its mouth and to the front with its paws. But this would screw the whole gravity etc, so thats not an option. So i guess he needs to rotate the Root CapsuleComponent inside its base class or? :X So that scaling its height would result in a vertical scaling.

Rereading 's first response to your solution, I see it is basically the same solution I’ve illustrated. However just to be clear, unlike the picture, the capsule would need to touch the ground. A common misconception is that the capsule needs to engulf the character entirely. This is not true: You can position the capsule so it looks like a wolf on a stick with the “stick” just making through to the wolf’s back. (This does not need to be in the center either, it can be positioned through the wolf’s head and front legs with the tail end hanging out.)
Hence, there is no need to rotate the mesh 90°.

Then you have the option to create physics assets for the wolf or, as I’ve illustrated, add collision components to key joints so that the parts outside the capsule can return hit data and not go through walls and other barriers. Since you can add collision to the bones in UE4, no need to add collision in the 3D modeling program.

Hi -
Is this really the case? I’ve experimented a fair amount with doing this for NPCs which don’t fit very well in a capsule. What I find is that the additional collision components (a physics asset in my case) only work to prevent other moving things from penetrating into the NPC. However, when the NPC itself moves, the physics collision objects will go right through the environment or the player. My understanding is that only the capsule is considered when doing movement.
Without breaking the vertical capsule restriction, perhaps the only way to really handle this is to detect overlaps on the other collision components and attempt to push the character away yourself.

Hi Xanen,

You wrote, “Without breaking the vertical capsule restriction, perhaps the [way to] handle this is to detect overlaps on the other collision components and attempt to push the character away yourself.”

I agree this is another way to achieve collision for a character that does not fit the capsule exactly. My response was for a player character setting the collision (in my example, “punch collision”) to “block all” as well as setting the collision of the meshes the character interacts with.

I am not using a physics assets in the illustration above but adding collision to the wrist bones. In case of a wolf or dog I would add those the head and tail area. (btw in the illustration, I realize the capsule is wrong… in that case the character would fall to the floor until it reached the bottom of the capsule.)

So this is the easiest way I know to compensate for the capsule not being able to extend horizontally without using code. Your solution would work as well and I’m sure there are a few other workarounds.

Surely though the central issue is that UCharacterMovementComponent must be making the assumption that the character’s collision consists of a single upright capsule? If this is true, then there will be no straightforward way of having different collision shapes without rewriting large parts of the movement component. If it’s not the case, then why would there have been the need to restrict a character to having this root capsule component in the first place?

Hi Kamrann,

I’ve taken a screenshot to better illustrate my solution, which I believe is the easiest and most practical. The capsule in this instance controls the primary interaction with the world and the collision modules around the head and hind quarters serve to prevent the character from going through walls and to trigger player overlap events: (You could even get more specific with smaller collisions around individual joints)

However, this is by no means the only solution. You could in fact create a pawn and generate a rectangular box around the dog to act as the capsule. This approach, however, requires you having to rebuild the character blueprint from scratch defining all movement inputs etc.and is why I did not suggest this initially.

Finally, you could use code to generate a custom capsule, two capsules, etc. but is much more involved.

serve to prevent the character from
going through walls

I don’t believe this is the case at all, which is what I was referring to in my original post. From everything I’ve seen, only the capsule component is considered for movement collision. Certainly, you can use the hind/tail components for detecting overlaps and for blocking other things from moving into the wolf. However, those collision components won’t be considered when moving the wolf itself. As kamrann says, if that weren’t the case, why would there be the capsule restriction to begin with?

Hi Xanen,

I stand corrected on my initial, “easy” solution. After some further testing the collision added to the head and tail do not prevent the character from penetrating the walls and other static meshes. My previous answer was based on the hands in the above pic interacting with dynamic objects and moving them around. (I’m still testing settings to see if this can work.)

However, the second solution offered, creating a custom capsule from box, sphere, or capsule collision at the pawn level and then setting that pawn to be your player character will work, but as I mentioned before, setting the character blueprint up will be more involved -but easier than coding it in C++.

Thanks for your feedback

Thanks Heerbann. Could explain what you meant by splitting your mesh into various actors and how that specifically would prevent clipping through walls? Thank you

Well, you need to split your meshes in blender or similar into various meshes. No idea how that works with animations.
The clipping is very simple: the capsule is the root of the collision tree in the character and ignores any collision of its children. if you want the capsule to collide with a body part, this part must not be part of this tree (-> not a child of the capsule).
The easiest way is to attach ChildActor component to your character, which allows to attach other actors to you Character.
For example in my gif I simply hid the head of the bear and attached a camera boom with a ChildActor attached to it. The other actor is simply a sphere mesh. Now the capsule collides with the head when the head collides with the wall. (the capsule needs to be able to collided with this actor. If it cant collide with the actor it will clip!)

Yes with the invisible mesh would obviously work, but kinda defeats the purpose to go thru all that trouble and not having the visual effect of bumping the head or something like this. I stay with my opinion that such an attachment should only be used when really necessary to not get stuck all the time.

Important is that the attached collider must not touch the capsule except when bumping into something. The child actor needs to be able to move or it will clip. That’s why the sping arm but there are better solutions Im sure.

Thanks, that’s a very interesting solution. I’m not sure I really understand the process, but I’ll need to explore that. Can you post a screenshot of the components tab of your character blueprint? I think you’re on to a brilliant solution here, but I think there must be a way to use a single mesh for your character and then use a separate invisible mesh for collision (or a collision volume?) as a ChildActor.

Thanks so much for that extra info and posting the screenshot. That is very helpful. Since the main purpose is to block movement and prevent penetration of the character mesh into other meshes, I think this forms the important ground work for the first viable solution we have ever really had. Have a great day!

Without breaking the vertical capsule restriction, perhaps the only way to really handle this is to detect overlaps on the other collision components and attempt to push the character away yourself.

this is a old question but it was never really answered. and that’s annoying because it’s one of the first question that shows up on google. So I will give it a try.

Why a capsule and why not to change it.

Even if you have a quadruped character you don’t want to change the capsule to some other bounding volume. Even if it were possible. There is a good reason.
In a game that is mostly horizontal (as on the xy hyperplane) you always want a smooth concave shape that ideally has no “corners” so you dont get stuck in the piece-wise smooth and sometimes convex geometry with all kinds of edges and hooks that is the game world. If we cut the world in layers parallel to the xy hyperplane we observe that the capsule is always a circle and that’s ideal. It’s exactly what we want.
That doesnt mean that you will not collide with the colliders/ physics asset/ skeletal mesh of a clone of yourself and vice versa.

But I want to have a head or something to bump into walls and dont want it to clip

In that case you need to split your mesh into various actors and put the parts together with sockets and child actors. This could look something like this:

300875-2020-04-29-21-36-19.gif

Moral of the story: use the capsule. Don’t try to rewrite the movement component just to realise it was a dumb idea.

edit (deprecated) : I only tried it so far with camera boom and in that case yes it works as expected but the collider of the attached mesh is ignored and only the collider of the camera boom is used. will find a better solution

edit2: Now we are getting somewhere. When you have a following set-up: capsule → spring-arm → childActor the spring arm will do the actual colliding and “move” the childActor towards the capsule until it collides. Yes the capsule will collide with the childActor.
Now, the question is how much sense does this make. The best move forward is to attach a bunch of springarms with decent sized probes and leave away the childActors altogether in order to “extend” the capsule.