So i want to make the turret of a tank and a CHILD of it, go back and forth when shooting, so this is what i've done :
IEnumerator Gun1BackandForth()
{
// when i shoot i call this Coroutine to move the position
//of the tank on the y and then return it ( to tank position) :
Vector3 position = Gun1Transform.position;
position.y -= 0.1f;
Gun1Transform.position = position;
yield return new WaitForSeconds(0.05f);
Gun1Transform.position = transform.position;
}
it works great ! but when the tank is rotated, the turret keeps go DOWN, like it's not a child of the tank, it does follow the tank but when shooting and reducing the y value, the turret goes down always. isn't the turret suppesed to have new coordinations because it's a child? please help !
↧