C++ Camera Controlled Turrets

Hi, ! Thanks for your tutorial. Now I have finished this tutorial project and the barrel can fire a projectile, everything is OK now!
But I have some other problems when I create a new project by using the skills I learned in the tutorial.
Now, I’d like to add a turret and a barrel to the tank body, the tank body comes from Skeletal Mesh and I can use WSAD to drive it and use Space Bar to handbrake it. Just as I did in the tutorial, I added some sockets in the Skeletal Mesh and Static Mesh, …, but it seems that they cannot work together! The tank body drives well then it works alone, the turret and the barrel also work OK without the tank body. I doubt the Skeletal Mesh and Static Mesh can’t work together by using this method.
Can you give me some guidance? What should I do to make a tank whose body is Skeletal Mesh and it can run and fire?
Sorry to trouble you again. O(∩_∩)O~

You’re not troubling me at all!

Now I’ve never used the skeletal mesh for a vehicle. Is there a specific reason why your using a skeletal mesh on a solid body? I believe it should work though, unless you need to make a skeletal mesh for the turret for it to be compatible, but again, that shouldn’t be a problem.

Now correct me if I misunderstood what your saying:

  1. Vehicle body works and drives when turret isn’t spawned onto the vehicle.
  2. Turret works well when it isn’t spawned onto the vehicle body.
  3. When the body and turret are put together (as in you spawn the turret in) nothing works, Turret wont move and you can’t drive the vehicle around.

Digging around I found this little excerpt on answerhub:
"to sum it up : Attach events doesnt work properly with "Skeletal mesh component " but they work fine with " Native skeletal mesh component " . and you cant solve this by parenting the " native skeletal mesh component " to the camera , since it cant be moved , renamed , deleted .well that seems like an issue to me anyway .

How to solve :move your skeletal mesh from “skeletal mesh component” to “native skeletal mesh component " then in graph of the character blueprint , add an “attach to” node and attach " native skeletal mesh” to camera when begin playing ."

It sounds like it could be an issue with how the skeletal mesh is set up. Also take a look at the following link, is this how you set up the sockets your trying to use?

Or do you have the sockets set up like in my tutorial?

Thank you, . Under your guidance, I have finished the work with skeletal mesh.

I use a skeletal mesh as my vhicle body because I want to make it run by its wheels and bones just as the UE4 Demo shows. Under your advice, I also use skeletal mesh to make my vehicle’s turret and barrel instead of static mesh.

The three points you said are all right! I have seen the tutorial of sheletal mesh.

Without your help, I can’t finish these works. Salute to you again!

Awesome that it’s working! You should take a short video of it in progress! I’m definitely interested in your project now!

And I’m happy I could help, always willing to help a fellow developer :slight_smile: We all learn together right?

Oh! Very happy to make friend with you and very happy we can learn together! I will show you my project as soon as possible.

This project will work through the hardware and LAN, now I have finished the hardware controller by USB in stm32(MCU) and some functions have been realized by software you have seen. Do you know the game named World of Tanks? My project is a bit like it.I will achieve it step by step.

If you need any assistance in solving issues or just need someone to bounce your train of thought off of, feel free to PM me. Love to help you progress further with your game!

Thank you for your concern and help, I am very happy to meet you!

Alright, I got around to redo the whole thing in an empty project.
Still the same problem, Mousewheel zoom is working but that’s it.
No camera rotation or moving the ship.
Either I did the same mistake twice or something in the tutorial is not working as expected.
Next time I get time I’ll try with the code scorpio_b put into one of his posts to try if that works for me.

Okay, thank you for the verification. I stepped through the tutorial again and its working on my end. I’ll try it on a different machine, I’m thinking I might have something unique set up so I’ll compare it with scorpio’s code he posted and ammend the tutorial.

Hi, ! I find it strange now. No camera rotation or moving when I use static mesh, but the camera works OK when I use skeletal mesh. Though my code works when I use static mesh, but has many imperfect places.
Now in my new project I use skeletal mesh and 's code, the camera works well.

I am still pretty sure the mistake is on my end.
Since I am switching to skeletal meshes in the near future anyway I will report in as soon as I have tested with those.

Thanks for your support guys!

Hello, ! I have trouble in rotating the turret of a tank now. There is a skeletal mesh named Tank whose root bone is called Tank_Bone, it has a turret whose bone is called Turret_Bone. By learning your tutorial, I can find the bone of the turret, but I don’t know how to control it. Can you give me some advice? Thank you.

Just to clarify, are you able to spawn the turret? Is it just the case of not being able to make the turret look at the camera vector?

No, I don’t meant that. I have finished the project whose turret and body are seperated ones a month ago. Now the turret and the body are in the same skeletal.

Hey Scorpio, sorry for the silence, life took up most of my free time so I haven’t been able to visit the forums for awhile.

So as to your issue I believe what the issue is just how the structure is built. The tutorial assumes that the turret and body will always be separate classes. If the body and turret are together as one object becomes one class. So what you want to do is anything I do in the turretbase classes, is to integrate it with the shipbase classes. Since the turret logic will need to reference the proper hierarchy. It’ll become slightly messy but I do have an old project that does this. You can abstract things out as you go, but in the situation your in, the best first step is to combine the shipbase and turretbase classes. Make sure to update any references to the turretmesh so it points at your turret bone.

Hope this helps! Again sorry for such a long delay in my response.

Nice to meet you again! I will try the method you said, now I am trying to solve the problem in blueprints. Thanks for your help!

Hi ,

A big thank you, Sir, for your tutorial and time.
Although I used only 10 lines form it, but they are important!

It is sad that Epic closed this old wiki site, seems as it was a “must have” source for high level game features not covered in the engine.