I am experimenting with a simple 2D sidescroller game in which the player can shoot arrows. I have made plenty of projectiles before, but for some reason I cannot figure this one out. I absolutely cannot figure out how to make the arrow projectile have the correct rotation when it is shot. It fires in the correct direction, but the arrow fires upright, with the tip pointing down, 90 degrees from the travel direction, instead of pointing forward with velocity.
I have tried:
Rotating the capsule collision and paper flipbook. This works if I have a scene component as root for my projectile, but I need the capsule collision to be root for collisions to work properly.
Setting the initial velocity on a different axis (arrow no longer shoots in correct direction)
Rotating the arrow 90 degrees, either in its own begin play or the transform on spawn. This has no effect.
This worked. I was trying to avoid doing that as I would have to re-extract the sprites, etc, but I suppose this is the best solution. Thanks. Still feel like there has to be a way.
Correction: This actually did not solve the problem. It only rotated the sprite out of the capsule collider. Re-orienting the sprite in the capsule collider returns the problem.
Yes, this works just fine for me too. The complication comes when I add a capsule collider and make it root (this is needed for projectile collision to work correctly, as I understand it). The capsule collider always wants to stand upright, never horizontal.
I have sort of circumvented the problem by using a sphere collider on the head of the arrow, instead of a capsule on the entire arrow. Its the arrow head that does the damage anyway. With the sphere collider, I can now simply set pivot on the arrowhead and rotate the sprite, a luxury I didn’t have with the capsule.
That’s not true. Capsules can have whatever orientation you want.
However, the root component cannot be rotated differently from the actor itself.
Maybe what you want to do is to either rotate the actor, or make a “Scene” root component, and add the sprite and the capsule as children of that, orienting them as appropriate?