I have a game (top down 2d) and i have several problems
The whole project can be downloaded here https://www.mediafire.com/?f0n0grifi7m5ccg
I have 5 scripts and the problems are the following:
Script #1 Move Problem:The tank never rotates to the right when i press “D”
using UnityEngine;
using System.Collections;
public class Move : MonoBehaviour {
public float speed;
public float rotspeed;
void Update () {
if (Input.GetKey (KeyCode.W))
transform.Translate (new Vector2 (0, speed * Time.deltaTime));
if (Input.GetKey (KeyCode.S))
transform.Translate (new Vector2 (0, -speed * Time.deltaTime));
if (Input.GetKey (KeyCode.A))
transform.Rotate (new Vector3 (0,0, rotspeed * Time.deltaTime));
if (Input.GetKey (KeyCode.D))
transform.Translate (new Vector3 (0,0, -rotspeed * Time.deltaTime));
}
}
Script #2 Shell Problem:The tanks bullets clone Shell(clone) should ignore collision with the tank(because the bullet has the script and it gets cloned)
using UnityEngine;
using System.Collections;
public class Shell : MonoBehaviour {
public Transform Hull;
void Start() {
Physics.IgnoreCollision(Hull.collider, collider);
}
}
Script #3 Health Problem:**The tank has a HP system(very basic),the tank should take damage from the Shell2(Clone)<- The enemys bullets clone(Not tested yet-no enemy yet-)but
the tank disappears after entering playmode after 2-3seconds or not and it gets a -12 z transform(A 2D GAME) here is the script
using UnityEngine;
using System.Collections;
public class Health : MonoBehaviour {
public float health;
public float dam;
void OnCollisionEnter2D (Collision2D col)
{
if (col.gameObject.name == "Shell2(Clone)")
{
health = health-dam;
}
if (health <= 0)
Destroy (this.gameObject);
}
}
The other scripts and the whole project can be downloaded here https://www.mediafire.com/?f0n0grifi7m5ccg
Thanks if you can help me
Oh and what do you think of the game thats my first one?
The other scripts and the whole project can be downloaded here https://www.mediafire.com/?f0n0grifi7m5ccg