我已经尝试了许多其他解决方案,但没有一个对我有用。
即使我使用AddForce
.
这是代码
public Transform gunExitPoint;
public int ProjectileVelocity;
public GameObject projectilePref;
void Update()
{
if (Input.GetKeyDown(KeyCode.Mouse0))
{
GameObject shot = Instantiate(projectilePref, gunExitPoint.position, gunExitPoint.rotation);
Rigidbody2D rb = shot.GetComponent<Rigidbody2D>();
rb.AddForce(transform.forward * ProjectileVelocity * Time.deltaTime, ForceMode2D.Impulse);
}
}