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)
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
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