Solution for spawning and attaching different types of actors to an actor?

I have an archer character with bow and arrow attached to the skeletal mesh. When I shoot an arrow, another arrow actor itentical to the arrow mesh is spawned. If I want to have different types of arrows with different material and particle effects, what would be the best implementation?

I got as far as spawning an arrow in the arrow socket. It follows the character but it seems to be randomly blocking my movement. The fired arrow is also misalinged with this extra static arrow.

One way to do this is to create some sort of projectile actor. Inside it you can manage projectile movement, hit effects, damage and so on, without overcomplicating the main character blueprint. Then you can just spawn that actor on demand with whatever info you need - geometry, velocity, target and so on. And if you need different projectile types you can subclass it and just change the parameters you need, but keeping the main logic in a single place.
About the blocking - make sure your arrow has no collision with the character

Tried that. There is only one problem so far. I need to spawn the arrow in a special arrow socket to get the correct placement, and then it doesn’t follow the right hand. If I attach it to the right hand the position and rotation is messed up.

The default arrow mesh looks alright though, but I can’t use that for the functionality I want(as far as I know). So how do I make the spawned/attached arrow follow the hand?

After spawning the arrow actor you can use AttachActorToActor, or AttachActorToComponent to position it at the socket you need.
On the attach options change the location/rotation/scale rules from Keep Relative to Snap To Target

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.