Hey, hoping someone can shed some light on this for me or point me in the correct direction.
I have a pawn (tank) with a child actor (turret) attached via a spring arm so it doesn’t inherit the pawn’s rotation.
I’m able to move+rotate the pawn, and rotate the turret independently… everything looks fine. However; I’ve noticed that when I rotate the pawn, the forward vector of the turret changes while the pawn is moving and returns to what it looks like it should be when the rotation stops. Visually, it’s impossible to tell (printing the forward vector shows the issue, not the static mesh/actor) but it means that if the player shoots the turret while turning the tank, the projectiles (given velocity based on the turret’s forward vector) won’t shoot where the turret is pointing.
Any ideas?
The pawn uses FloatingPawnMovement component, and is turned with the AddActorWorldRotation node.
The turret is rotated with SetActorRotation, which is only called when given user input (right analog stick)
The amount that the forward vector drifts from what it ought to be seems to be determined by the rate of rotation.
I think this is because the turret is a child actor instead of a component of the Actor. It’s constantly rotating COUNTER to the actor itself, instead of being paired to it.
I think the answer here is actually not using the actor forward, but maybe a component chain with a scene node(empty) to use as the spawning point that is a child of the barrel. That being said this seems like we’ll need to fiddle with it a bit to get it nailed down.
Hope this helps, let us know what you figure out and we can further narrow down a solution!
That makes sense that it’s constantly rotating counter to the pawn to give the impression that it’s stationary.
Had a fiddle around with making a component chain instead of child actor, but was getting the same result.
Had a think about how to completely separate the two pieces and managed to get things behaving how I want by making the turret into its own entirely separate pawn (owned by the same player controller), and checking its location on tick relative to a scene node on the tank pawn (and moving it if need be). No longer fighting against the Tank pawn’s rotation input!