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;
}
If you don't format your code, you usually don't get answers. Select your code and use the 101/010 button. I've formatted it for you this time.
– robertbuThank you for telling me that ,I will take care of it,the first time ever to show my question here, I will try to learn it
– Death_sickleYou can put in screenshots to help other understand what you have and you might get answers faster.
– Chronos-Lwhat do you mean when you say current level?
– RainbowMurderStrike