Hi, I’m pretty new in using unity. I have been trying to make simple a top down shooter game.
The script I’m using to move the tank around is this
#pragma strict
var Tank:Transform;
//Movement
var acceleration: float=1;
var maxSpeed: float;
//Rotation
var rAcc: float=0;
var maxTurnspeed: float=100;
function Start () {
}
function Update () {
//Tank movement
Tank.Translate(1*acceleration*Vector3.forward*Time.deltaTime);
if (Input.GetAxisRaw("Vertical")==1){
if (acceleration < maxSpeed) {
acceleration += 1;
}
}
if (Input.GetAxisRaw("Vertical")==-1){
if(acceleration>-maxSpeed){
acceleration-=1;
}
}
if (Input.GetButton("Jump") == true){
if(acceleration > 0){
acceleration = acceleration - 1;
}
if(acceleration < 0){
acceleration = acceleration + 1;
}
}
//Tank rotation
Tank.Rotate(rAcc*Vector3.up*Time.deltaTime);
if (Input.GetAxisRaw("Horizontal")==1){
Tank.Rotate(maxTurnspeed*Vector3.up*Time.deltaTime);
}
if (Input.GetAxisRaw("Horizontal")==-1){
Tank.Rotate(maxTurnspeed*Vector3.down*Time.deltaTime);
}
}
Is there a simple way to make gravity affect the tank?
My second question is about the tank going trough everything, it has character controller attached to it, but it doesn’t collide with anything. The hitbox seems to be capsule.