Results 1 to 2 of 2
  1. #1
    Join Date
    May 2011
    Posts
    3

    Problem with 2d shooter tutorial

    Dear all,

    I am following 2d Shooter tutorial but i am having problemas with the bullet-enemy collision detection:

    I've already add a Rigid Body component to the Projectile Prefab and marked the "trigger" label on the Enemy. This is projectile code:


    using UnityEngine;
    using System.Collections;

    public class Projectile : MonoBehaviour {

    // Use this for initialization
    void Start ()
    {

    }

    public float ProjectileSpeed;



    // Update is called once per frame
    void Update ()
    {
    float amountToMove = ProjectileSpeed * Time.deltaTime;
    transform.Translate(Vector3.up * amountToMove);

    if (transform.position.y > 6.4f)
    {
    Destroy(gameObject);
    }
    }

    void OnTriggerEnter(Collider otherObject)
    {
    if (otherObject.tag == "enemy")
    {
    Destroy(otherObject.gameObject);
    }

    }


    }

  2. #2
    Join Date
    May 2011
    Posts
    3
    Dont worry guys, already solved it by myself! Thx anyway

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •