in this script i dont know if i have a problem but i want it so when my player touches the truck it dies… the truck and player both have rigidbodiesand box colliders please help!
Sccript on player:
using UnityEngine;
using System.Collections;
public class jump : Enitity {
void OnCollisionEnter2D(Collision2D coll)
{
if (coll.gameObject.tag == “truck”)
Destroy(gameObject);
}
public float speedForce = 50f;
public Vector2 jumpVector;
void Update()
{
Movement();
}
void Movement()
{
if (Input.GetKey(KeyCode.D))
{
transform.Translate(Vector2.right * 8f * Time.deltaTime);
}
if (Input.GetKey(KeyCode.A))
{
transform.Translate(Vector2.left * 8f * Time.deltaTime);
}
if (Input.GetKey(KeyCode.W))
{
transform.Translate(Vector2.up * 8f * Time.deltaTime);
}
}
}
love if someone can help cause im new (●´ω`●)