I’m a noob, failing at selecting a prefab from a dropdown ui, before instantiating.
Any ideas would be great because I keep hitting dead ends, and trial and error has not been kind to me. Thanks
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class fireProjectile : MonoBehaviour
{
public Dropdown ammoDropdown;
public Rigidbody ammo00;
public Rigidbody ammo01;
void Update()
{
if (ammoDropdown.value == 0)
{
//Make ammo00 the projectile
}
else
{
projectile = null;
}
if (Input.GetButtonDown("Fire1") && projectile != null)
{
Rigidbody clone;
clone = Instantiate(projectile, transform.position, transform.rotation);
clone.velocity = transform.TransformDirection(Vector3.forward * 10);
}
}
}