So I’m aiming to have a marshmallow shoot out a projectile on click, and currently my target is to make it spawn on click. Though it spawns at the top right which I cannot seem to fix. Any help greatly appreciated!
The error =
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SpawnProjectile : MonoBehaviour
{
public GameObject firePoint;
public List<GameObject> vfx = new List<GameObject>();
private GameObject effectToSpawn;
void Start()
{
effectToSpawn = vfx[0];
}
void Update()
{
if(Input.GetMouseButton(0))
{
SpawnVFX();
}
}
void SpawnVFX()
{
GameObject vfx;
if(firePoint != null)
{
vfx = Instantiate(effectToSpawn, firePoint.transform.position, Quaternion.identity);
}
else
{
Debug.Log("No Fire Point");
}
}
}
Why did you add the code at line 26?
This will change the position of the VFX to the position of the game object that the scripts sit on.
I think you can remove that line.