Download

Turrets on moving platforms

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:

  1. 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.
  2. Use the inverse of that transform to rotate the target position into the local coordinate system of the turret’s socket.
  3. 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?

Figured it out. The problem was that I was asking for sockets in the wrong place; after I fixed that derp, everything started working again.

https://www.youtube.com/watch?v=0-dlPhMhVNM

Buying this game FOR SURE when your done!!! Please have pre-order reward :smiley:

Hi there, are your turrets implemented as individual Blueprints attached to your Ship blueprint? if so, how did you get them to move with the ship?
When I try doing something like this for multiplayer the turrets don’t move with the main hull blueprint :frowning:

Banging my head against the wall trying to make multi-crewed vehicles with turrets in a multiplayer environment but no matter what I try the turrets either can’t be possessed or don’t move with the parent Blueprint.

would pay to have a copy of this bp/code! :slight_smile: