How to rotate my tank turret with my mouse?

Hi all,

I looked lot of tutorial for turret control and applied them all, but no one worked…
I tried the last and simpliest way to rotate the turret and the barrel of the turret, but nothing move when I’m moving my mouse.

I think my problem is that my “Axis Z turret BP” variable value can’t get to my “Transform (modify) Bone” node, but I don’t know why, so if someone know where is my error, please tell me what I did wrong.

In Pawn blueprint “Event graph”:

In Pawn animation “Event graph”:

In Pawn animation “animation”:

PS: Sorry for my bad english

also ensure that “Event Update Animation” is even getting called.

also in the last screenshot, it is possible that your second “Transform (modify) Bone” node overrides the effect of the first one, making only Y variable count.
to avoid that, remove one of the nodes, and leave only one, feeding in a rotation which is combination of both Y and Z. (just plug both floats into the same “make rotator”).

I make the test like you say, and it seem that the cast don’t work correctly.
You can see on the second picture that sometimes the cast work and sometimes failed.
Maybe the the object for the cast is wrong, but I don’t know with what I can replace it

can you ensure the cast to “Mini_Veh_Armor_Car” calls success pin?
to check it you can connect printString to fail/success pin to inform you of that.

take this one step further, and check if the pawn “is valid” before trying to cast it.

I look further but not find how to see if it "is valid so I put string on the pawn value (in dark blue in the picture) and anim value (in red).

So we can see that in the picture:

  • the 2 value communicate, but the cast sometimes goes wrong
  • the turret transform don’t get the value

So I think that the problem is in the animation, maybe the “transform node” transmit the value only at beginning but don’t still modify after…

i don’t unserstand which values do you mean by red and blue, but anyway, to check if the object is value, just drag it to a node which is called “is valid”. every UActor has such function (node).

So, I check if the object is valid, and it is.

The animation “event graph” blueprint :

The animation “animation” blueprint (still be the same than before (Itried to just use one “transform” node, but the result is the same)):

The “event graph” Pawn blueprint :

I put the rotation of the barrel and the turret to 45°:

Here is the result in edition mode (I get what I want):

But when the simulation is launched, the turret and barrel don’t move with mouse movement or still have the 45°:

if “is valid” returns false, it means that the object does not exist. you can’t do anything with that object therefore.
try this.

sorry, the last picture is false there is the good one, and it show that the “is valid” return true

the base class of base class of Mini_Veh… is a “blueprint pawn wheeledvehicle” and the pawn from the Animgraph belong to the skeletal mesh who is in the “blueprint pawn wheeledvehicle”

what is the unreal base class of Mini_Veh…?
also, what class does the pawn of the AnimGraph belong to?