November 2018
Beginner
246 pages
5h 23m
English
In the following code, we can see our TankController class. First, we set up our Start function and the Update functions.
The code in the PlayerTankController.cs file is as follows:
using UnityEngine; using System.Collections; public class PlayerTankController : MonoBehaviour { public GameObject Bullet; private Transform Turret; private Transform bulletSpawnPoint; private float curSpeed, targetSpeed, rotSpeed; private float turretRotSpeed = 10.0f; private float maxForwardSpeed = 300.0f; private float maxBackwardSpeed = -300.0f; //Bullet shooting rate protected float shootRate = 0.5f; protected float elapsedTime; void Start() { //Tank Settings rotSpeed = 150.0f; //Get the turret of the tank Turret = gameObject.transform.GetChild(0).transform; ...Read now
Unlock full access