Hi,
I’ve been stuck on this problem for 2 days and I have completely exhausted things to try, its very frustrating as I know the fix will probably be a stupid oversight.
I have a Synty asset character with a bow shooting animation and i’ve scripted a method to shoot based on a button hold time. When the threshold time is reached it will instantiate an arrow prefab that has a script to handle its ‘launching’. The code currently below allows me to fire at the correct time in the direction of the player but the arrow is constantly facing downwards.
Worth noting, the imported arrow model used naturally faces ‘downwards’ but even when I correct the rotation (x to -90) in the transform it doesn’t fix the issue.
Could someone please review my janky code and point me in the right direction? Thank you
edit: GoTowards() is called in the Arrow FixedUpdate() script
Bow Class:
public void Shoot(Vector3 movement)
{
// float to check if you are moving the joystick to aim
float aiming = _anim.GetFloat("Speed_f");
_shooting = CrossPlatformInputManager.GetButton("Shoot");
if (_shooting)
{
// start timer to check how the button is held down for to release arrow in time with animation
_timePressed = _timePressed += Time.deltaTime;
_anim.SetFloat("Speed_f", 0);
_anim.SetBool("Reload_b", true);
_anim.SetBool("Shoot_b", true);
if (_timePressed > 1.45 && aiming > 0.1)
{
_arrowCount++;
if (_arrowCount < 2)
{
Instantiate(Arrow, ArrowSpawn.transform.position, transform.rotation);
Debug.Log(Arrow.transform.rotation);
}
if (_timePressed > 1.8)
{
_anim.SetBool("Shoot_b", false);
_timePressed = 0;
_arrowCount = 0;
}
}
else if (_timePressed > 1.3 && aiming < 0.05)
{
_anim.SetBool("Shoot_b", false);
_timePressed = 0;
}
}
Arrow Script:
public void GoTowards()
{
transform.rotation = Quaternion.LookRotation(GameObject.FindGameObjectWithTag("Player").GetComponent<Transform>().forward);
_rb.velocity = transform.forward * ShotForce;
_fired = true;
}