Quando disparo a bala, ela sai girando sem direção. Qual o problema?
Controle da arma
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BulletControl : MonoBehaviour
{
public GameObject Bullet;
public GameObject GunBarrel;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if(Input.GetButtonDown("Fire1")){
Instantiate(Bullet, GunBarrel.transform.position, GunBarrel.transform.rotation);
}
}
}
Controle da bala
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Bullet : MonoBehaviour
{
public float Velocity = 20;
// Update is called once per frame
void FixedUpdate ()
{
GetComponent<Rigidbody>().MovePosition (GetComponent<Rigidbody>().position + transform.forward * Velocity * Time.deltaTime);
}
}