Merminiz 'u ateşliyor Sürekli olarak bir mermi uyguladım, ama yukarı çıkmış gibi görünüyor, neyi yanlış yaptım?Merminiz devam ediyor
public class Player1Controls : MonoBehaviour {
// Update is called once per frame
public float speed;
Rigidbody2D player;
public float health;
private int state;
public Rigidbody2D Bullet;
public GameObject Gun;
void Start()
{
player = GetComponent<Rigidbody2D>();
}
void Update()
{
if (Input.GetKeyDown(KeyCode.Space))
{
Rigidbody2D bullet1 = (Rigidbody2D)Instantiate (Bullet, Gun.transform.position,Quaternion.identity);
}
if(Input.GetKey(KeyCode.W))
{
//transform.Translate(Vector2.up * speed);
player.velocity =(Vector2.up*speed);
state = 1;
}
public class MoveBullet: MonoBehaviour {
public float speed;
// Update is called once per frame
void Update() {
Vector3 pos = transform.position;
Vector3 vel = new Vector3(0, speed * Time.deltaTime, 0);
pos = pos + transform.rotation * vel;
transform.position = pos;
}
Hızınızı sadece y yönünde ayarlayabilirsiniz. Oyuncunun vektörü boyunca olmalı. – schultz