Hello
I try to make my player shoot arrows with my own character controller and the arrow is being instantiated in the right place but not moving afterwards here is the code
void Start()
{
Screen.lockCursor = true;
speed = 8;
}
// Update is called once per frame
void Update()
{
if(timer >= 1.5f || timer == 0)
{
timer = 0;
airTime = 0;
DrawArrow();
}
else
{
if(shot)
timer += Time.deltaTime;
}
}
void FixedUpdate () {
Debug.Log(timer + " " + shot);
moveDirection = (arrowPrefab.transform.rotation * Vector3.forward);
Debug.Log(moveDirection * speed);
moveDirection *= speed;
if(!arrowPrefab.GetComponent<CharacterController>().isGrounded){
arrowPrefab.GetComponent<CharacterController>().Move(moveDirection * speed);
arrowPrefab.transform.Rotate(0, Time.deltaTime * speed, 0);}
}
private void DrawArrow()
{
if(Input.GetButton("Fire1"))// starts drawing
{
shot = true;
Debug.Log("FIRE AT WILL");
Vector3 pos = new Vector3(transform.position.x, transform.position.y + 2, transform.position.z + 2);
Instantiate(arrowPrefab, pos, transform.rotation);
arrowPrefab.transform.rotation = Quaternion.Euler(30, 0, 0);
}
}
ty very much