Answer the question
In order to leave comments, you need to log in
How to set an impulse in the direction of motion in 2d?
2d game, you need to set an impulse so that the bullet moves in the direction the parent object is looking. Of all that I went through, only came up
void Fire()
{
Debug.Log("Fire");
curTimeout += Time.deltaTime;
if (curTimeout > fireRate)
{
curTimeout = 0;
Rigidbody2D clone = Instantiate(bullet, gunPoint.position, Quaternion.identity) as Rigidbody2D;
clone.transform.up = gunPoint.up;
clone.velocity = clone.transform.up * speed;
Debug.Log("выстрел произошёл");
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question