Multiple projectiles not firing straight

Good day all, and happy easter.

I have a project where I want to fire multiple cannons from the side of my vessel.

The cannons activate a spawn, and the spawned actor (cannon ball) has a projectile component.

the issue is that there seems to be a problem with the spawning side of the transform as none of the projectiles shoot straight. And as you can see, it is not a random event, they shoot ‘straight’ everytime but not relative to the cannons/actor.

when i do a print text debug on the cannon balls, their relative is always 90%, so they are shooting ‘striaght’.

Anyone had this problem before?
Should i be ‘forcing’ the rotation at spawn?

Can you post the full code for the spawn?
What is driving the start location and rotation? Is it a passed in cannon mesh component? Perhaps an offset in the form of a scene component?

Are the cannons actor components or separate meshes or is the whole ship 1 mesh?

1 Like

Sure,

I have a pawn actor. (Boat)

Calling a custom even ton the cannons (port or starboard)

and once the cannonballs are spawned, they are given a projectile velocity.

I thought it was straight forward (no pun intended). I spawn at a socket on the cannons and the projectile should inherit the relative rotation of the cannons?

I also have the tried this with only 1 cannon on its own, and it still fires off direction from where the red line is.

You seem to be getting the sockets world transform. I would probably go with local transform. I would need to test it out in a test scene but I’m not sure if it’s space is in world space then it may be changed with the parent rotation (not a 100% sure through).

I would try to make a rotation from x from the local space of the socket and make sure the socket’s x is pointing forward.

Did a quick test scene
cannonTest.zip (118.9 KB)

world space seems to work ok

Even if I rotate the ship + cannons, they fire in the expected directions.

1 Like

So changed the location of the transform to actor and or component. When i do actor, it uses the actors transform for some reason, and when i do the component, it shoots at a weird location underneath the boat.

I am guessing it is not locating the socket properly? I have double checked the socket name.
yet, in the world transform option, all sockets work.

Interesting thing too, every time i run a separate test, it will choose a different location to shoot all the projectiles. e.g. it will shoot under cannon 1, then under cannon 4, then 2. random transform locations.

I am very confused. in the world transform option, X vector is what I use, in the component/actor, I have to use Y vector.

Apologies, and thanks for the help. I am new, and I am sure it is simply a step I missed while setting up the actors/meshes.

So there must be something effecting the spawn do you think? manipulating the world direction when spawned?

Are you sure the socket name is correct in the get socket transform? Perhaps it has a space on the end? Go into the static mesh of the cannon => go to sockets and try copying the socket name directly (I think you have to trigger a rename).

That is the only thing that really comes to mind atm.

It should work as with the blueprints. I swapped my skinned meshes for statics + sockets and it fires ok as well.

2 Likes

ok, so i figured out it was being effected by the collision box of the boat. I had to retweak the collision box and now they shoot straight.
Thanks for the helping hand. you helped me problem solve this and gave be direction, greatly appreciated.

2 Likes

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