Download

Vehicle with movable component: How to approach it?

Since this is my first post here, I don’t want to neglect giving a friendly ‘hello’. :slight_smile:

I am very new to the Unreal Engine and I am currently working on a small project for the sake of getting my feet wet and being prepared for future endeavours. The situation seems to be rather simple, I want to add a vehicle with an exchangeable, animated component. Therefore I have been digging in the API-documentation and trying to find a good, if not the optimal way to handle this. There seem to be several, so any hint would be highly appreciated. :slight_smile:

Right now I think that I might want to subclass USkeletalMeshComponent. My assumption is that by doing this I could animate the component itself, but I am not sure if I can animate the whole component as part of the vehicle, too.

As an example: Imagine a car with a mountable gun. Now the gun can be animated (due to subclassing USkeletalMeshComponent) and the vehicle can be animated. But how would I turn the gun itself around? Is that easily possible using USkeletalMeshComponent or should I pursue another path all together?

I would be happy about any constructive input. :slight_smile:

I just found this article: Modular Pawn

This suggests that the topic discussed in the first post should be realizable without an extreme amount of effort. However, the article seems outdated (the parameter passed to the constructor looks strange) and the last lines of code hint at a mistake. Also, there is no mention of how to animate the full pawn, including the different components. The article sadly is not much more than a little teaser, a promising one. Is anybody around who can give me hints on whether the animation of a multi-component pawn is possible and how to approach it?

To elaborate on the example from the article: Assume I create a full human pawn, with head, two arms, two legs etc. If I now want to have the character do a dodge-roll, would the process of creating the animation become extremely tedious or is there an easy way I am not seeing?

I am digging into other parts of the engine while I hope for some enlightenment here. UE4 is just the best thing ever.

How is what you are attempting to do different from just an actor hierarchy? IE the gun is parented to the car.

Thank you for your answer. :slight_smile: I don’t know how it would be different or not. Neither do I know what exactly you are referring to with an “actor hierarchy” (though I assume you mean components attached to a mesh). And, as I mentioned before, I do not yet know if complex animations would be possible with something like the modular Pawn I linked to in my last post. Could it easily be forced to do, for example, a backflip?

I would like to know which route to take to basically create a nicely animated, “modular Pawn”.

No not an Actor and attached components, just a simple hierarchy. Ignore Unreal for a minute. This is an agnostic concept in animation. If you have one thing parented to another, then the child moves with the parent, but can still be animated independently in relation to its parent.

In Unreal, open up a scene and drop in say a Cylinder and a Cube. In the World Outliner drag and drop the “Cube” label on top of the “Cylinder” label. You will see that unreal parents the Cube to the cylinder and it represents this by showing the Cube indented under the Cylinder.

Now in the viewport, note that if you move the cylinder around, the cube comes for the ride. But also note you can transform the cube in local space, even while it is being moved by the cylinder.

Now Imagine the cylinder is a car, and the cube is a mounted gun. With the gun parented to the car, it will go wherever the car goes, but can still do its own animation as well.

EDIT: I said Actor parented to Actor, but you could do the same thing with components if you wanted. The concept is the same.

Ok, this doesn’t sound foreign, I have seen and used this in other programs. But I don’t see how I would do an actual animation. A properly, fluently backflipping modular Pawn? Then I would have to code the animation, and that sounds like a terribly ugly, inefficient and insufficient solution. The gun on the car might work like this, but that might have been too simple of an example.

The Turret can be part of the same Mesh if it has to be (and really it probably should be for simplicity sake, unless you want to attach a ‘Turret’ component to multiple objects) - You just parent it to a bone and move the bone as if it’s the turret.

EDIT: Just-Reread, what you’re doing isn’t much different to having weapons on Characters. The weapon itself is another Actor, and is attached to a bone on the other object. Whenever the bone moves in the SkeletalMesh, the turret will follow. To rotate the turret, rotate the bone or the turret mesh. Easy really!

you can create vehicle with simple body mesh without VISUAL wheels(or other parts), but with skeleton bones for wheels, and then create sockets on vehicle skeleton(for example for changeable wheels, because mesh geometry don’t using in vehicle physics, and your wheels for example easy can be looks like a box or like a character or other 3d model…), and attach your objects(meshes) to this socket, or if you have vehicle with gun you can create Gun bp(like separate pawn) and attach all This gun bp to yore vehicle(in this case you can posses player in Gun bp or in vehicle, it be good for 2 players vehicle) hereexample with vehicle BP and gun BP

Thanks for your replies. Sounds like components/sockets/Actor hierarchies are a good way to go for now. Maybe I will follow the short example for the modular Pawn, since I am still not entirely sure if I could make it clap its hands (the hands being components of arms which would be components on a body).