Question by
askar270296 · Apr 28, 2019 at 08:37 AM ·
scripting beginner
I need help, I need that the projectile hit the the enemy that goes to him that is coming at him, my gun code from which I shoot
my code
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class spawnGuns : MonoBehaviour {
public Transform target;
public GameObject Bullet;
public Transform point;
float speed = 5f;
public void Update()
{
}
void OnMouseDown()
{
GameObject bull = Instantiate(Bullet, point.position, point.rotation);
bull.GetComponent<Rigidbody2D>().AddForce(point.transform.right * speed, ForceMode2D.Impulse);
print("contact");
}
}
the projectile I have has a rigid body komnonet and has weight, how can I convert the code so that I can calculate the future position of the troll and hit it
Comment