November 2018
Beginner
246 pages
5h 23m
English
The player's tank is the simple tank model we used in the previous chapter, with a non-kinematic rigid body component attached. We need the rigid body component to generate trigger events whenever we do collision detection with AI characters and environment objects. Finally, we need to assign the Player tag to our tank.
As we can easily see from its name, the PlayerTank script controls the player's tank. The following is the code for the PlayerTank.cs file:
using UnityEngine; public class PlayerTank : MonoBehaviour { public Transform targetTransform; public float movementSpeed, rotSpeed; void Update () { //Stop once you reached near the target position if (Vector3.Distance(transform.position, targetTransform.position) < ...Read now
Unlock full access