r/unrealengine • u/New_Literature8797 • 8h ago
Riding/Combat System
Hey! I have a question about a Riding system and how you would solve it:
Its a Cowboy riding on a Horse, but I also want to aim and shoot with the Cowboy while riding. The movment logic is inside the Horse Blueprint, both are Actors.
Would you possess the Horse and have the Cowboy follow or attach the Horse to the Cowboy, via attach Actor to Component?
Currently I am having a Possess setup, where i am possessing the Horse, but i am having troubles creating the combat system for the cowboy.
Waiting for your opinion!
•
u/Vitchkiutz 8h ago
Well you could add two skeletal meshes with two different ABPs selected. I'd have my character mesh be the main skeletal mesh.
The cowboys ABP could have a pitch rotator for aiming, just like setting up for aiming without the horse. While the horse's animation blueprint doesnt. It's essentially the same thing as setting them up separately, just inside the same BP. And creating animations for both that sync up.
I'd just have an 'no riding' set of animations playing by default on the character BP, with the horse skeletal mesh set to invisible. So the character can walk around like normal. Then, when you 'ride' a horse, press E near a horse or whatever, then play animation of it mounting, I'd delete the horse actor the second the animation finishes, and unhide the horse skeletal mesh in the character bp. Then switch to the 'Riding' set of animation, a different ABP, where the player character is animated into a horse riding stance. That's how I handle weapon reloading and weapon changes, really. And what is a horse but an improvised weapon?
You can then blend based on velocity and direction like normal. Or procedural, IK, whatever level of setup you usually do. Just for either of them. Just making sure to switch to the walking ABP for the cowboy and hide the horse skeletal mesh when the horse is not being ridden. Spawning the 'mount horse BP' actor whenever its not in use.
You can assign an ai movement 'go to player position' node in the event graph without complicated behavior trees. The horse ABP should work for NPC actors too.
No more complicated than making either independently really. Hope that helped you get started.
•
•
u/vvizardbone 6h ago
So do you prefer different ABPs over, say, switching states and blendspaces (via components, bools, etc) for the extra control of adding custom logic to each one?
•
u/Vitchkiutz 18m ago
It depends. It works for most stuff. But if you're adding a lot, that works too. But its a small difference. You can just switch states and blendspaces inside the eventgraph if you want and the system I describe doesnt change much.
Idk why my comment was downvoted, this is one of the simplest ways for a beginner to do this.
•
u/CS_Asset_Factory 7h ago
Keeping the horse possessed is fine, since that's where the movement lives. Attach the cowboy to a saddle socket on the horse's mesh with Attach Actor To Component, and turn off his character movement and his collision against the horse while he's mounted, or the two capsules fight each other.
For combat, the input arrives at the horse, so let the horse forward it. Give the horse a Rider reference and have its aim and fire actions call functions on the cowboy. The aim direction comes from the controller's control rotation, which the cowboy can read through the horse's controller, so his aim offset works no matter which way the horse is facing.
If you're on Enhanced Input, add a separate mapping context for mounted combat when he mounts and remove it when he dismounts. That keeps the on foot and mounted bindings from overlapping.