Setting AutoTurret gun direction same as parent object?
Hi Guys,

I'm trying to put autoturret on car and it was going pretty good until I've tried to force the aiming direction. 
What I need is the turret to always aim forward in the same direction the car is rotated.
I was able to stop it from scanning the surroundings and turn of the trigger but the turret.aimdir is not being updated and it's always targeting the same poind in the world. 

The code below represents roughly what is happening in FixedUpdate (I don't have my code with me now - will update it later) 

void FixedUpdate()
{
    var rot = car.transform.localRotarion;
    turret.aimdir = new Vector3(rot.x, rot.y, rot.z);
    turret.UpdateAiming();
}
​

Once the AutoTurret is being turned online it points to the correct direction but the gun does not rotate with the car.

Any ideas?


Thank you in advance
turret.transform.rotation ?
I have tried this already and it did not work.

I think I was not specific enough on the problem: Right now the base of the turret does stick to the car entity and rotates and travels correctly, the problem is the gun itself that stays focused on a specific point in world. So when I set the turret online it's facing forwatd, but when I turn left the gun starts aiming right (relatively to car).
So that's the issue. Take a deeper look at the game code, maybe you just need something like Vector3.Forward :) or something more complicated
I have already checked the files. How the aiming is done is basically like this:
  1. turret finds a target
  2. Turret.SetTarget() updates the aimdir vector
  3. Turret.UpdateAiming() changes the gun_yaw and gun_pitch according to the aimdir vector

The thing I don't understand is why the Update Aiming() does not change the pitch and yaw even if the aimdir is changing correctly (checked that) while called by FixedUpdate(), but it still sets both values correctly when the turret is being spawned.

I don't know what I'm missing here...