made a video to show the problem and the instantiate code is below that
public void CastSpell()
{
EnableMagicSigil();
playerManager.playerStats.TakeManaDamage(currentSpell.manaCost);
//spell doesnt hold
if (!currentSpell.spellHolds)
{
Ray ray = cam.ViewportPointToRay(new Vector3(0.5f, 0.5f, 0));
RaycastHit hit;
if (Physics.Raycast(ray, out hit))
destination = hit.point;
else
{
//default value was just 1000 set back to that if infinity causes problems
destination = ray.GetPoint(Mathf.Infinity);
}
InstantiateProjectile();
}
else if (currentSpell.spellHolds)
{
var projectileObj = Instantiate(currentSpell.spellProjectileVFX, playerManager.leftHandSpellSpawnPoint.position, playerManager.transform.rotation) as GameObject;
}
}
private void InstantiateProjectile()
{
var projectileObj = Instantiate(currentSpell.spellProjectileVFX, playerManager.leftHandSpellSpawnPoint.position, playerManager.transform.rotation) as GameObject;
projectileObj.GetComponent<Rigidbody>().velocity = (destination - playerManager.leftHandSpellSpawnPoint.position)
.normalized * currentSpell.spellSpeed;
}