So, I got this problem that I thought I had solved already, but as it turns out, I only solved it for the not very useful case of my ships not actually moving.
Here’s the issue: The game I want to do features a bunch of big spaceships. There are multipart turrets (i.e. turrets with distinct bodies and barrels) mounted on them, and since this is space, those turrets can be mounted at arbitrary angles.
Now, in order to get them to rotate towards a target, I have to do the following:
- Get the base transform of the socket the turret is mounted on. This should give me the world space location and rotation of the turret socket.
- Use the inverse of that transform to rotate the target position into the local coordinate system of the turret’s socket.
- Using that, derive a target direction for my turret to be pointing at, using the yaw value for the base rotation and the pitch value for the barrel’s rotation.
The problem is that when I implement that behaviour in Blueprint, I get invalid results. What am I doing wrong? Is there some essential math step I missed?