New to BP and visual scripting and trying my best to learn, I’m trying to create basic tank functionality, most of what i have so far is pretty simple and i have been able to figure things out, however this has me wondering.
I’m trying to get the turret to maintain rotation with the hull (ignore my terrible model its just for learning) Currently on flat ground everything seems fine but when i have any kind of angled terrain i cant figure out how to alter the rotation to match the angle as seen in the video provided, any ideas here would be greatly appreciated as I’ve spent hours trying to figure this out…
Its probably something super simple and ill kick myself when i find out what I’m doing wrong…
some of the relevant BP Scripts:
(sorry for the eye pain with how messy i am lol)
So the problem here is that the turret is not locked to the body in the Y axis. It does seem locked in X rotation, which is good, but you need to lock the Y axis for the turret, letting it rotate in Z, and allow the BARREL to rotate in Y for the up and down. You’ll need a third mesh for that, that would be just the barrel with the anchor point at its base within the turret.
Not sure how you have constructed your tank model, but if you are using a skeletal mesh, and one of the bones is responsible for the orientation of the turret, you just need to constrain the bone’s rotation so that it stays oriented with its parent on all but the vertical axis.
It’s 3 static mesh components, “tank”, “turret”, and “gun”. He shows it in the pictures. IN FACT…
Hey again @mattaktive, sorry for the extra post but after a sleep and taking another look at that components list… I realized you do have what you need. There was a post back in '22 that will work for this, It’s a little long but informative.
You need to work this in as relative rotation, not world, but using world values. Here’s the post! You may be able to tag ClockworkOcean on the current thread for any parts of their solution you don’t understand, I know they’re still around! Just make sure to read the whole thing as there are some red herrings early on in the thread due to miscommunications.
Thanks for having a look into this, my apologies for the slow replies, work life balance and all, i did do some digging and found this but i was kind of confused by the corrected BP at the end with the max rotation, I did in-fact try to replicate this but it forced the turret to look at a fixed point in the world rather than maintain the rotation on Y to the camera.
Are you able to give any clarity on how this Max distance VAR could be functioning?
Thanks for the time to look into this and help, I have tried this approach too but ran into some snags (my knowledge over anything) If i cant get past this rotation issue this is my next option, only as I’ve sunk a number of hours trying to achieve this with the separate components.
can I ask, working this way to get the rotation i presume you have a animation BP alongside a event graph BP to get things working? also the collision kind of confuses me, is this using basic collision set by UE5? Currently with the separate components I’m using UCX collision on the hull and physics/ collision on the parent component in the hierarchy.
Probably the wrong way to work this as later on down the line it could cause issues if i wanted to simulate and track projectile hits on the components but I’m thinking way to far ahead for now lol.
I am using the Chaos Vehicle Movement Component. It provides the physics for me. The body is set to simulate physics. The wheels are all kinematic per CVMC. The turret and barrel are set to kinematic so that they can rotate to aim precisely without physics interfering; any acceleration of their turning I need to simulate myself (no problem).
The body, the turret, each wheel, all have primitive collision bodies.
The exclusive reason I was using a skeletal mesh was due to CVMC works only with skeletal mesh.
I put together a video on the tank treads. While CVMC supports numerous wheels, it doesn’t directly support treads. You can see the Animation BP in the video.
But to be honest, I am thinking of rolling my own and not using Epic’s vehicle [anything] component. I have been struggling with multiplayer replication issues for more than a week. The replication from server to Client is fine. But I cannot get the Client to replicate to the Server with anything remotely usable. I am going to spend a few more days on this and then decide what I want to do next.