I attach the Cannon.cs to the cannon to fire the rope(Link joint) with mouse aim.But When I shoot the rope,the rope is invisible,and the speed is not fast,why?
public void Fire(Vector3 pos)
{
//point to target
Vector3 fireDir = pos -transform.position;
float angle = Mathf.Atan2(fireDir.y,fireDir.x)*Mathf.Rad2Deg;
transform.rotation = Quaternion.Euler(new Vector3(0,0,angle));
//spawn the rope
GameObject bullet = Instantiate(bullets[currentLevel-1],new Vector3(transform.position.x,transform.position.y,0),Quaternion.identity) as GameObject;
bullet.transform.rotation = transform.rotation;
Bullet bul = bullet.GetComponent();
bul.moveDir = new Vector3(fireDir.x,fireDir.y,0);
bul.level = currentLevel;
}
↧