- Home /
This post has been wikified, any user with enough reputation can edit it.
how tank and barrel move and rotate
Hi I want to make tank game.But tank does not move and rotate.I wanted to move barrel of tank up and down.Then body of tank rotate and move.Please help me...
Comment
Answer by SavaTim · Apr 15, 2020 at 10:52 PM
https://youtu.be/d8MZanCg3EA Look at this and Suscribe me !!!!! public class Tank : MonoBehaviour { public Transform TankGun; public float RotationSpeed; float Yang; // Start is called before the first frame update void Start() {
}
// Update is called once per frame
void Update()
{
if (Input.GetKey(KeyCode.Q))
{
Yang -= Time.deltaTime * RotationSpeed;
}
if (Input.GetKey(KeyCode.E))
{
Yang += Time.deltaTime * RotationSpeed;
}
TankGun.rotation = Quaternion.Euler(new Vector3(TankGun.rotation.eulerAngles.x, Yang, TankGun.rotation.eulerAngles.z));
}
}
Your answer
Follow this Question
Related Questions
Animating Tank Treads 0 Answers
fire tank in any direction 1 Answer
Multiplayer projectiles collision 0 Answers
player on trigger enter dont work? 1 Answer
Tank Setup Problem 1 Answer